History

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

Pull networking fixes from David Miller: "A little more than usual this time around. Been travelling, so that is part of it. Anyways, here are the highlights: 1) Deal with memcontrol races wrt. listener dismantle, from Eric Dumazet. 2) Handle page allocation failures properly in nfp driver, from Jaku Kicinski. 3) Fix memory leaks in macsec, from Sabrina Dubroca. 4) Fix crashes in pppol2tp_session_ioctl(), from Guillaume Nault. 5) Several fixes in bnxt_en driver, including preventing potential NVRAM parameter corruption from Michael Chan. 6) Fix for KRACK attacks in wireless, from Johannes Berg. 7) rtnetlink event generation fixes from Xin Long. 8) Deadlock in mlxsw driver, from Ido Schimmel. 9) Disallow arithmetic operations on context pointers in bpf, from Jakub Kicinski. 10) Missing sock_owned_by_user() check in sctp_icmp_redirect(), from Xin Long. 11) Only TCP is supported for sockmap, make that explicit with a check, from John Fastabend. 12) Fix IP options state races in DCCP and TCP, from Eric Dumazet. 13) Fix panic in packet_getsockopt(), also from Eric Dumazet. 14) Add missing locked in hv_sock layer, from Dexuan Cui. 15) Various aquantia bug fixes, including several statistics handling cures. From Igor Russkikh et al. 16) Fix arithmetic overflow in devmap code, from John Fastabend. 17) Fix busted socket memory accounting when we get a fault in the tcp zero copy paths. From Willem de Bruijn. 18) Don't leave opt->tot_len uninitialized in ipv6, from Eric Dumazet" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (106 commits) stmmac: Don't access tx_q->dirty_tx before netif_tx_lock ipv6: flowlabel: do not leave opt->tot_len with garbage of_mdio: Fix broken PHY IRQ in case of probe deferral textsearch: fix typos in library helpers rxrpc: Don't release call mutex on error pointer net: stmmac: Prevent infinite loop in get_rx_timestamp_status() net: stmmac: Fix stmmac_get_rx_hwtstamp() net: stmmac: Add missing call to dev_kfree_skb() mlxsw: spectrum_router: Configure TIGCR on init mlxsw: reg: Add Tunneling IPinIP General Configuration Register net: ethtool: remove error check for legacy setting transceiver type soreuseport: fix initialization race net: bridge: fix returning of vlan range op errors sock: correct sk_wmem_queued accounting on efault in tcp zerocopy bpf: add test cases to bpf selftests to cover all access tests bpf: fix pattern matches for direct packet access bpf: fix off by one for range markings with L{T, E} patterns bpf: devmap fix arithmetic overflow in bitmap_size calculation net: aquantia: Bad udp rate on default interrupt coalescing net: aquantia: Enable coalescing management via ethtool interface ...

Linus Torvalds committed 9 years ago

Commit b5ac3be2 parents e5f468b 8d5f4b0113 files · +1735 −689Browse files

Unified · Split

113 files
  1. drivers/net/can/flexcan.c +76 −15
  2. drivers/net/can/usb/esd_usb2.c +1 −1
  3. drivers/net/can/usb/gs_usb.c +2 −8
  4. drivers/net/dsa/mv88e6060.c +8 −2
  5. drivers/net/ethernet/amazon/ena/ena_ethtool.c +2 −2
  6. drivers/net/ethernet/amazon/ena/ena_netdev.c +4 −3
  7. drivers/net/ethernet/aquantia/atlantic/aq_cfg.h +6 −2
  8. drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +99 −58
  9. drivers/net/ethernet/aquantia/atlantic/aq_hw.h +3 −2
  10. drivers/net/ethernet/aquantia/atlantic/aq_nic.c +30 −9
  11. drivers/net/ethernet/aquantia/atlantic/aq_nic.h +3 −1
  12. drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +10 −4
  13. drivers/net/ethernet/aquantia/atlantic/aq_vec.c +3 −0
  14. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +10 −11
  15. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +49 −40
  16. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h +3 −0
  17. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +55 −14
  18. drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +13 −5
  19. drivers/net/ethernet/broadcom/bnxt/bnxt.c +73 −26
  20. drivers/net/ethernet/broadcom/bnxt/bnxt.h +5 −0
  21. drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c +18 −5
  22. drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +7 −1
  23. drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +9 −2
  24. drivers/net/ethernet/cavium/liquidio/lio_main.c +1 −1
  25. drivers/net/ethernet/ibm/ibmvnic.c +8 −8
  26. drivers/net/ethernet/intel/i40e/i40e_nvm.c +1 −1
  27. drivers/net/ethernet/intel/i40e/i40e_txrx.c +36 −27
  28. drivers/net/ethernet/mellanox/mlxsw/core.c +10 −1
  29. drivers/net/ethernet/mellanox/mlxsw/reg.h +31 −0
  30. drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +10 −1
  31. drivers/net/ethernet/netronome/nfp/nfp_net_common.c +14 −6
  32. drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c +5 −3
  33. drivers/net/ethernet/realtek/r8169.c +0 −2
  34. drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +1 −1
  35. drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +1 −1
  36. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 −8
  37. drivers/net/geneve.c +0 −6
  38. drivers/net/macsec.c +2 −0
  39. drivers/net/tun.c +3 −0
  40. drivers/net/wimax/i2400m/fw.c +1 −1
  41. drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +2 −1
  42. drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +97 −100
  43. drivers/net/wireless/intel/iwlwifi/cfg/7000.c +1 −0
  44. drivers/net/wireless/intel/iwlwifi/cfg/8000.c +1 −1
  45. drivers/net/wireless/intel/iwlwifi/cfg/9000.c +1 −1
  46. drivers/net/wireless/intel/iwlwifi/cfg/a000.c +1 −1
  47. drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h +2 −0
  48. drivers/net/wireless/intel/iwlwifi/fw/dbg.c +2 −5
  49. drivers/net/wireless/intel/iwlwifi/fw/dbg.h +15 −0
  50. drivers/net/wireless/intel/iwlwifi/iwl-config.h +14 −2
  51. drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +62 −75
  52. drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +7 −0
  53. drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +4 −1
  54. drivers/net/wireless/intel/iwlwifi/mvm/nvm.c +15 −6
  55. drivers/net/wireless/intel/iwlwifi/mvm/rx.c +3 −1
  56. drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +3 −1
  57. drivers/net/wireless/intel/iwlwifi/mvm/tt.c +1 −1
  58. drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +1 −1
  59. drivers/of/of_mdio.c +27 −12
  60. include/linux/filter.h +1 −1
  61. include/linux/netdevice.h +3 −0
  62. include/net/inet_sock.h +1 −1
  63. include/net/tcp.h +5 −0
  64. kernel/bpf/arraymap.c +1 −1
  65. kernel/bpf/devmap.c +7 −3
  66. kernel/bpf/hashtab.c +0 −4
  67. kernel/bpf/sockmap.c +18 −10
  68. kernel/bpf/verifier.c +51 −14
  69. lib/ts_fsm.c +1 −1
  70. lib/ts_kmp.c +1 −1
  71. mm/memcontrol.c +0 −15
  72. mm/percpu.c +10 −5
  73. net/bridge/br_netlink.c +1 −1
  74. net/can/af_can.c +16 −4
  75. net/can/bcm.c +3 −2
  76. net/core/dev.c +3 −3
  77. net/core/dev_ioctl.c +12 −1
  78. net/core/ethtool.c +2 −3
  79. net/core/filter.c +16 −15
  80. net/core/rtnetlink.c +10 −3
  81. net/core/skbuff.c +5 −1
  82. net/core/sock.c +5 −3
  83. net/core/sock_reuseport.c +9 −3
  84. net/dccp/ipv4.c +8 −5
  85. net/ipv4/Kconfig +3 −5
  86. net/ipv4/cipso_ipv4.c +7 −17
  87. net/ipv4/inet_connection_sock.c +4 −5
  88. net/ipv4/inet_hashtables.c +1 −4
  89. net/ipv4/syncookies.c +1 −1
  90. net/ipv4/tcp_input.c +1 −1
  91. net/ipv4/tcp_ipv4.c +13 −9
  92. net/ipv4/udp.c +3 −6
  93. net/ipv6/ip6_flowlabel.c +1 −0
  94. net/ipv6/ip6_output.c +2 −2
  95. net/l2tp/l2tp_ppp.c +3 −0
  96. net/mac80211/key.c +17 −4
  97. net/ncsi/internal.h +1 −0
  98. net/ncsi/ncsi-aen.c +1 −1
  99. net/ncsi/ncsi-manage.c +33 −19
  100. net/ncsi/ncsi-rsp.c +1 −1
  101. net/netlink/af_netlink.c +4 −4
  102. net/packet/af_packet.c +16 −8
  103. net/rxrpc/af_rxrpc.c +3 −2
  104. net/sched/cls_flower.c +2 −0
  105. net/sctp/input.c +1 −1
  106. net/sctp/socket.c +4 −0
  107. net/vmw_vsock/hyperv_transport.c +18 −4
  108. samples/sockmap/sockmap_kern.c +1 −1
  109. tools/include/uapi/linux/bpf.h +2 −1
  110. tools/testing/selftests/bpf/bpf_helpers.h +1 −1
  111. tools/testing/selftests/bpf/sockmap_verdict_prog.c +2 −2
  112. tools/testing/selftests/bpf/test_maps.c +11 −1
  113. tools/testing/selftests/bpf/test_verifier.c +508 −2
drivers/net/can/flexcan.c+76−15
@@ -182,22 +182,23 @@ · 181 unmodified lines
182182 /* FLEXCAN hardware feature flags
183183 *
184184 * Below is some version info we got:
185− * SOC Version IP-Version Glitch- [TR]WRN_INT Memory err RTR re-
186− * Filter? connected? detection ception in MB
187− * MX25 FlexCAN2 03.00.00.00 no no no no
188− * MX28 FlexCAN2 03.00.04.00 yes yes no no
189− * MX35 FlexCAN2 03.00.00.00 no no no no
190− * MX53 FlexCAN2 03.00.00.00 yes no no no
191− * MX6s FlexCAN3 10.00.12.00 yes yes no yes
192− * VF610 FlexCAN3 ? no yes yes yes?
185+ * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re-
186+ * Filter? connected? Passive detection ception in MB
187+ * MX25 FlexCAN2 03.00.00.00 no no ? no no
188+ * MX28 FlexCAN2 03.00.04.00 yes yes no no no
189+ * MX35 FlexCAN2 03.00.00.00 no no ? no no
190+ * MX53 FlexCAN2 03.00.00.00 yes no no no no
191+ * MX6s FlexCAN3 10.00.12.00 yes yes no no yes
192+ * VF610 FlexCAN3 ? no yes ? yes yes?
193193 *
194194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
195195 */
196−#define FLEXCAN_QUIRK_BROKEN_ERR_STATE BIT(1) /* [TR]WRN_INT not connected */
196+#define FLEXCAN_QUIRK_BROKEN_WERR_STATE BIT(1) /* [TR]WRN_INT not connected */
197197 #define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */
198198 #define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */
199199 #define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */
200200 #define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based offloading */
201+#define FLEXCAN_QUIRK_BROKEN_PERR_STATE BIT(6) /* No interrupt for error passive */
201202
202203 /* Structure of the message buffer */
203204 struct flexcan_mb {
@@ -281,14 +282,17 @@ struct flexcan_priv { · 77 unmodified lines
281282 };
282283
283284 static const struct flexcan_devtype_data fsl_p1010_devtype_data = {
284− .quirks = FLEXCAN_QUIRK_BROKEN_ERR_STATE,
285+ .quirks = FLEXCAN_QUIRK_BROKEN_WERR_STATE |
286+ FLEXCAN_QUIRK_BROKEN_PERR_STATE,
285287 };
286288
287−static const struct flexcan_devtype_data fsl_imx28_devtype_data;
289+static const struct flexcan_devtype_data fsl_imx28_devtype_data = {
290+ .quirks = FLEXCAN_QUIRK_BROKEN_PERR_STATE,
291+};
288292
289293 static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {
290294 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
291− FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
295+ FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_BROKEN_PERR_STATE,
292296 };
293297
294298 static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
@@ -335,6 +339,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr) · 40 unmodified lines
335339 }
336340 #endif
337341
342+static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
343+{
344+ struct flexcan_regs __iomem *regs = priv->regs;
345+ u32 reg_ctrl = (priv->reg_ctrl_default | FLEXCAN_CTRL_ERR_MSK);
346+
347+ flexcan_write(reg_ctrl, &regs->ctrl);
348+}
349+
350+static inline void flexcan_error_irq_disable(const struct flexcan_priv *priv)
351+{
352+ struct flexcan_regs __iomem *regs = priv->regs;
353+ u32 reg_ctrl = (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_MSK);
354+
355+ flexcan_write(reg_ctrl, &regs->ctrl);
356+}
357+
338358 static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
339359 {
340360 if (!priv->reg_xceiver)
@@ -713,6 +733,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) · 372 unmodified lines
713733 struct flexcan_regs __iomem *regs = priv->regs;
714734 irqreturn_t handled = IRQ_NONE;
715735 u32 reg_iflag1, reg_esr;
736+ enum can_state last_state = priv->can.state;
716737
717738 reg_iflag1 = flexcan_read(&regs->iflag1);
718739
@@ -765,8 +786,10 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) · 46 unmodified lines
765786 flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);
766787 }
767788
768− /* state change interrupt */
769− if (reg_esr & FLEXCAN_ESR_ERR_STATE)
789+ /* state change interrupt or broken error state quirk fix is enabled */
790+ if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
791+ (priv->devtype_data->quirks & (FLEXCAN_QUIRK_BROKEN_WERR_STATE |
792+ FLEXCAN_QUIRK_BROKEN_PERR_STATE)))
770793 flexcan_irq_state(dev, reg_esr);
771794
772795 /* bus error IRQ - handle if bus error reporting is activated */
@@ -774,6 +797,44 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) · 1 unmodified line
774797 (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
775798 flexcan_irq_bus_err(dev, reg_esr);
776799
800+ /* availability of error interrupt among state transitions in case
801+ * bus error reporting is de-activated and
802+ * FLEXCAN_QUIRK_BROKEN_PERR_STATE is enabled:
803+ * +--------------------------------------------------------------+
804+ * | +----------------------------------------------+ [stopped / |
805+ * | | | sleeping] -+
806+ * +-+-> active <-> warning <-> passive -> bus off -+
807+ * ___________^^^^^^^^^^^^_______________________________
808+ * disabled(1) enabled disabled
809+ *
810+ * (1): enabled if FLEXCAN_QUIRK_BROKEN_WERR_STATE is enabled
811+ */
812+ if ((last_state != priv->can.state) &&
813+ (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_PERR_STATE) &&
814+ !(priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)) {
815+ switch (priv->can.state) {
816+ case CAN_STATE_ERROR_ACTIVE:
817+ if (priv->devtype_data->quirks &
818+ FLEXCAN_QUIRK_BROKEN_WERR_STATE)
819+ flexcan_error_irq_enable(priv);
820+ else
821+ flexcan_error_irq_disable(priv);
822+ break;
823+
824+ case CAN_STATE_ERROR_WARNING:
825+ flexcan_error_irq_enable(priv);
826+ break;
827+
828+ case CAN_STATE_ERROR_PASSIVE:
829+ case CAN_STATE_BUS_OFF:
830+ flexcan_error_irq_disable(priv);
831+ break;
832+
833+ default:
834+ break;
835+ }
836+ }
837+
777838 return handled;
778839 }
779840
@@ -887,7 +948,7 @@ static int flexcan_chip_start(struct net_device *dev) · 107 unmodified lines
887948 * on most Flexcan cores, too. Otherwise we don't get
888949 * any error warning or passive interrupts.
889950 */
890− if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_ERR_STATE ||
951+ if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_WERR_STATE ||
891952 priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
892953 reg_ctrl |= FLEXCAN_CTRL_ERR_MSK;
893954 else
drivers/net/can/usb/esd_usb2.c+1−1
@@ -333,7 +333,7 @@ static void esd_usb2_rx_can_msg(struct esd_usb2_net_priv *priv, · 332 unmodified lines
333333 }
334334
335335 cf->can_id = id & ESD_IDMASK;
336− cf->can_dlc = get_can_dlc(msg->msg.rx.dlc);
336+ cf->can_dlc = get_can_dlc(msg->msg.rx.dlc & ~ESD_RTR);
337337
338338 if (id & ESD_EXTID)
339339 cf->can_id |= CAN_EFF_FLAG;
drivers/net/can/usb/gs_usb.c+2−8
@@ -375,6 +375,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) · 374 unmodified lines
375375
376376 gs_free_tx_context(txc);
377377
378+ atomic_dec(&dev->active_tx_urbs);
379+
378380 netif_wake_queue(netdev);
379381 }
380382
@@ -463,14 +465,6 @@ static void gs_usb_xmit_callback(struct urb *urb) · 82 unmodified lines
463465 urb->transfer_buffer_length,
464466 urb->transfer_buffer,
465467 urb->transfer_dma);
466−
467− atomic_dec(&dev->active_tx_urbs);
468−
469− if (!netif_device_present(netdev))
470− return;
471−
472− if (netif_queue_stopped(netdev))
473− netif_wake_queue(netdev);
474468 }
475469
476470 static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
drivers/net/dsa/mv88e6060.c+8−2
@@ -214,8 +214,14 @@ static int mv88e6060_setup(struct dsa_switch *ds) · 213 unmodified lines
214214
215215 static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr)
216216 {
217− /* Use the same MAC Address as FD Pause frames for all ports */
218− REG_WRITE(REG_GLOBAL, GLOBAL_MAC_01, (addr[0] << 9) | addr[1]);
217+ u16 val = addr[0] << 8 | addr[1];
218+
219+ /* The multicast bit is always transmitted as a zero, so the switch uses
220+ * bit 8 for "DiffAddr", where 0 means all ports transmit the same SA.
221+ */
222+ val &= 0xfeff;
223+
224+ REG_WRITE(REG_GLOBAL, GLOBAL_MAC_01, val);
219225 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_23, (addr[2] << 8) | addr[3]);
220226 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_45, (addr[4] << 8) | addr[5]);
221227
drivers/net/ethernet/amazon/ena/ena_ethtool.c+2−2
@@ -742,8 +742,8 @@ static void ena_get_channels(struct net_device *netdev, · 741 unmodified lines
742742 {
743743 struct ena_adapter *adapter = netdev_priv(netdev);
744744
745− channels->max_rx = ENA_MAX_NUM_IO_QUEUES;
746− channels->max_tx = ENA_MAX_NUM_IO_QUEUES;
745+ channels->max_rx = adapter->num_queues;
746+ channels->max_tx = adapter->num_queues;
747747 channels->max_other = 0;
748748 channels->max_combined = 0;
749749 channels->rx_count = adapter->num_queues;
drivers/net/ethernet/amazon/ena/ena_netdev.c+4−3
@@ -966,7 +966,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring, · 965 unmodified lines
966966 u64_stats_update_begin(&rx_ring->syncp);
967967 rx_ring->rx_stats.bad_csum++;
968968 u64_stats_update_end(&rx_ring->syncp);
969− netif_err(rx_ring->adapter, rx_err, rx_ring->netdev,
969+ netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
970970 "RX IPv4 header checksum error\n");
971971 return;
972972 }
@@ -979,7 +979,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring, · 6 unmodified lines
979979 u64_stats_update_begin(&rx_ring->syncp);
980980 rx_ring->rx_stats.bad_csum++;
981981 u64_stats_update_end(&rx_ring->syncp);
982− netif_err(rx_ring->adapter, rx_err, rx_ring->netdev,
982+ netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
983983 "RX L4 checksum error\n");
984984 skb->ip_summed = CHECKSUM_NONE;
985985 return;
@@ -3064,7 +3064,8 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev) · 2078 unmodified lines
30643064 if (ena_dev->mem_bar)
30653065 devm_iounmap(&pdev->dev, ena_dev->mem_bar);
30663066
3067− devm_iounmap(&pdev->dev, ena_dev->reg_bar);
3067+ if (ena_dev->reg_bar)
3068+ devm_iounmap(&pdev->dev, ena_dev->reg_bar);
30683069
30693070 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
30703071 pci_release_selected_regions(pdev, release_bars);
drivers/net/ethernet/aquantia/atlantic/aq_cfg.h+6−2
@@ -22,8 +22,12 @@ · 21 unmodified lines
2222
2323 #define AQ_CFG_FORCE_LEGACY_INT 0U
2424
25−#define AQ_CFG_IS_INTERRUPT_MODERATION_DEF 1U
26−#define AQ_CFG_INTERRUPT_MODERATION_RATE_DEF 0xFFFFU
25+#define AQ_CFG_INTERRUPT_MODERATION_OFF 0
26+#define AQ_CFG_INTERRUPT_MODERATION_ON 1
27+#define AQ_CFG_INTERRUPT_MODERATION_AUTO 0xFFFFU
28+
29+#define AQ_CFG_INTERRUPT_MODERATION_USEC_MAX (0x1FF * 2)
30+
2731 #define AQ_CFG_IRQ_MASK 0x1FFU
2832
2933 #define AQ_CFG_VECS_MAX 8U
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c+99−58
@@ -56,10 +56,6 @@ aq_ethtool_set_link_ksettings(struct net_device *ndev, · 55 unmodified lines
5656 return aq_nic_set_link_ksettings(aq_nic, cmd);
5757 }
5858
59−/* there "5U" is number of queue[#] stats lines (InPackets+...+InErrors) */
60−static const unsigned int aq_ethtool_stat_queue_lines = 5U;
61−static const unsigned int aq_ethtool_stat_queue_chars =
62− 5U * ETH_GSTRING_LEN;
6359 static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
6460 "InPackets",
6561 "InUCast",
@@ -83,56 +79,26 @@ static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = { · 17 unmodified lines
8379 "InOctetsDma",
8480 "OutOctetsDma",
8581 "InDroppedDma",
86− "Queue[0] InPackets",
87− "Queue[0] OutPackets",
88− "Queue[0] InJumboPackets",
89− "Queue[0] InLroPackets",
90− "Queue[0] InErrors",
91− "Queue[1] InPackets",
92− "Queue[1] OutPackets",
93− "Queue[1] InJumboPackets",
94− "Queue[1] InLroPackets",
95− "Queue[1] InErrors",
96− "Queue[2] InPackets",
97− "Queue[2] OutPackets",
98− "Queue[2] InJumboPackets",
99− "Queue[2] InLroPackets",
100− "Queue[2] InErrors",
101− "Queue[3] InPackets",
102− "Queue[3] OutPackets",
103− "Queue[3] InJumboPackets",
104− "Queue[3] InLroPackets",
105− "Queue[3] InErrors",
106− "Queue[4] InPackets",
107− "Queue[4] OutPackets",
108− "Queue[4] InJumboPackets",
109− "Queue[4] InLroPackets",
110− "Queue[4] InErrors",
111− "Queue[5] InPackets",
112− "Queue[5] OutPackets",
113− "Queue[5] InJumboPackets",
114− "Queue[5] InLroPackets",
115− "Queue[5] InErrors",
116− "Queue[6] InPackets",
117− "Queue[6] OutPackets",
118− "Queue[6] InJumboPackets",
119− "Queue[6] InLroPackets",
120− "Queue[6] InErrors",
121− "Queue[7] InPackets",
122− "Queue[7] OutPackets",
123− "Queue[7] InJumboPackets",
124− "Queue[7] InLroPackets",
125− "Queue[7] InErrors",
82+};
83+
84+static const char aq_ethtool_queue_stat_names[][ETH_GSTRING_LEN] = {
85+ "Queue[%d] InPackets",
86+ "Queue[%d] OutPackets",
87+ "Queue[%d] Restarts",
88+ "Queue[%d] InJumboPackets",
89+ "Queue[%d] InLroPackets",
90+ "Queue[%d] InErrors",
12691 };
12792
12893 static void aq_ethtool_stats(struct net_device *ndev,
12994 struct ethtool_stats *stats, u64 *data)
13095 {
13196 struct aq_nic_s *aq_nic = netdev_priv(ndev);
97+ struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
13298
133−/* ASSERT: Need add lines to aq_ethtool_stat_names if AQ_CFG_VECS_MAX > 8 */
134− BUILD_BUG_ON(AQ_CFG_VECS_MAX > 8);
135− memset(data, 0, ARRAY_SIZE(aq_ethtool_stat_names) * sizeof(u64));
99+ memset(data, 0, (ARRAY_SIZE(aq_ethtool_stat_names) +
100+ ARRAY_SIZE(aq_ethtool_queue_stat_names) *
101+ cfg->vecs) * sizeof(u64));
136102 aq_nic_get_stats(aq_nic, data);
137103 }
138104
@@ -154,8 +120,8 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev, · 15 unmodified lines
154120
155121 strlcpy(drvinfo->bus_info, pdev ? pci_name(pdev) : "",
156122 sizeof(drvinfo->bus_info));
157− drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) -
158− (AQ_CFG_VECS_MAX - cfg->vecs) * aq_ethtool_stat_queue_lines;
123+ drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) +
124+ cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
159125 drvinfo->testinfo_len = 0;
160126 drvinfo->regdump_len = regs_count;
161127 drvinfo->eedump_len = 0;
@@ -164,14 +130,25 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev, · 2 unmodified lines
164130 static void aq_ethtool_get_strings(struct net_device *ndev,
165131 u32 stringset, u8 *data)
166132 {
133+ int i, si;
167134 struct aq_nic_s *aq_nic = netdev_priv(ndev);
168135 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
169−
170− if (stringset == ETH_SS_STATS)
171− memcpy(data, *aq_ethtool_stat_names,
172− sizeof(aq_ethtool_stat_names) -
173− (AQ_CFG_VECS_MAX - cfg->vecs) *
174− aq_ethtool_stat_queue_chars);
136+ u8 *p = data;
137+
138+ if (stringset == ETH_SS_STATS) {
139+ memcpy(p, *aq_ethtool_stat_names,
140+ sizeof(aq_ethtool_stat_names));
141+ p = p + sizeof(aq_ethtool_stat_names);
142+ for (i = 0; i < cfg->vecs; i++) {
143+ for (si = 0;
144+ si < ARRAY_SIZE(aq_ethtool_queue_stat_names);
145+ si++) {
146+ snprintf(p, ETH_GSTRING_LEN,
147+ aq_ethtool_queue_stat_names[si], i);
148+ p += ETH_GSTRING_LEN;
149+ }
150+ }
151+ }
175152 }
176153
177154 static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset)
@@ -182,9 +159,8 @@ static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset) · 4 unmodified lines
182159
183160 switch (stringset) {
184161 case ETH_SS_STATS:
185− ret = ARRAY_SIZE(aq_ethtool_stat_names) -
186− (AQ_CFG_VECS_MAX - cfg->vecs) *
187− aq_ethtool_stat_queue_lines;
162+ ret = ARRAY_SIZE(aq_ethtool_stat_names) +
163+ cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
188164 break;
189165 default:
190166 ret = -EOPNOTSUPP;
@@ -245,6 +221,69 @@ static int aq_ethtool_get_rxnfc(struct net_device *ndev, · 54 unmodified lines
245221 return err;
246222 }
247223
224+int aq_ethtool_get_coalesce(struct net_device *ndev,
225+ struct ethtool_coalesce *coal)
226+{
227+ struct aq_nic_s *aq_nic = netdev_priv(ndev);
228+ struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
229+
230+ if (cfg->itr == AQ_CFG_INTERRUPT_MODERATION_ON ||
231+ cfg->itr == AQ_CFG_INTERRUPT_MODERATION_AUTO) {
232+ coal->rx_coalesce_usecs = cfg->rx_itr;
233+ coal->tx_coalesce_usecs = cfg->tx_itr;
234+ coal->rx_max_coalesced_frames = 0;
235+ coal->tx_max_coalesced_frames = 0;
236+ } else {
237+ coal->rx_coalesce_usecs = 0;
238+ coal->tx_coalesce_usecs = 0;
239+ coal->rx_max_coalesced_frames = 1;
240+ coal->tx_max_coalesced_frames = 1;
241+ }
242+ return 0;
243+}
244+
245+int aq_ethtool_set_coalesce(struct net_device *ndev,
246+ struct ethtool_coalesce *coal)
247+{
248+ struct aq_nic_s *aq_nic = netdev_priv(ndev);
249+ struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
250+
251+ /* This is not yet supported
252+ */
253+ if (coal->use_adaptive_rx_coalesce || coal->use_adaptive_tx_coalesce)
254+ return -EOPNOTSUPP;
255+
256+ /* Atlantic only supports timing based coalescing
257+ */
258+ if (coal->rx_max_coalesced_frames > 1 ||
259+ coal->rx_coalesce_usecs_irq ||
260+ coal->rx_max_coalesced_frames_irq)
261+ return -EOPNOTSUPP;
262+
263+ if (coal->tx_max_coalesced_frames > 1 ||
264+ coal->tx_coalesce_usecs_irq ||
265+ coal->tx_max_coalesced_frames_irq)
266+ return -EOPNOTSUPP;
267+
268+ /* We do not support frame counting. Check this
269+ */
270+ if (!(coal->rx_max_coalesced_frames == !coal->rx_coalesce_usecs))
271+ return -EOPNOTSUPP;
272+ if (!(coal->tx_max_coalesced_frames == !coal->tx_coalesce_usecs))
273+ return -EOPNOTSUPP;
274+
275+ if (coal->rx_coalesce_usecs > AQ_CFG_INTERRUPT_MODERATION_USEC_MAX ||
276+ coal->tx_coalesce_usecs > AQ_CFG_INTERRUPT_MODERATION_USEC_MAX)
277+ return -EINVAL;
278+
279+ cfg->itr = AQ_CFG_INTERRUPT_MODERATION_ON;
280+
281+ cfg->rx_itr = coal->rx_coalesce_usecs;
282+ cfg->tx_itr = coal->tx_coalesce_usecs;
283+
284+ return aq_nic_update_interrupt_moderation_settings(aq_nic);
285+}
286+
248287 const struct ethtool_ops aq_ethtool_ops = {
249288 .get_link = aq_ethtool_get_link,
250289 .get_regs_len = aq_ethtool_get_regs_len,
@@ -259,4 +298,6 @@ const struct ethtool_ops aq_ethtool_ops = { · 8 unmodified lines
259298 .get_ethtool_stats = aq_ethtool_stats,
260299 .get_link_ksettings = aq_ethtool_get_link_ksettings,
261300 .set_link_ksettings = aq_ethtool_set_link_ksettings,
301+ .get_coalesce = aq_ethtool_get_coalesce,
302+ .set_coalesce = aq_ethtool_set_coalesce,
262303 };
drivers/net/ethernet/aquantia/atlantic/aq_hw.h+3−2
@@ -151,8 +151,7 @@ struct aq_hw_ops { · 150 unmodified lines
151151 [ETH_ALEN],
152152 u32 count);
153153
154− int (*hw_interrupt_moderation_set)(struct aq_hw_s *self,
155− bool itr_enabled);
154+ int (*hw_interrupt_moderation_set)(struct aq_hw_s *self);
156155
157156 int (*hw_rss_set)(struct aq_hw_s *self,
158157 struct aq_rss_parameters *rss_params);
@@ -163,6 +162,8 @@ struct aq_hw_ops { · 4 unmodified lines
163162 int (*hw_get_regs)(struct aq_hw_s *self,
164163 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);
165164
165+ int (*hw_update_stats)(struct aq_hw_s *self);
166+
166167 int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,
167168 unsigned int *p_count);
168169
drivers/net/ethernet/aquantia/atlantic/aq_nic.c+30−9
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include "aq_pci_func.h"
1717 #include "aq_nic_internal.h"
1818
19+#include <linux/moduleparam.h>
1920 #include <linux/netdevice.h>
2021 #include <linux/etherdevice.h>
2122 #include <linux/timer.h>
@@ -24,6 +25,18 @@ · 2 unmodified lines
2425 #include <linux/tcp.h>
2526 #include <net/ip.h>
2627
28+static unsigned int aq_itr = AQ_CFG_INTERRUPT_MODERATION_AUTO;
29+module_param_named(aq_itr, aq_itr, uint, 0644);
30+MODULE_PARM_DESC(aq_itr, "Interrupt throttling mode");
31+
32+static unsigned int aq_itr_tx;
33+module_param_named(aq_itr_tx, aq_itr_tx, uint, 0644);
34+MODULE_PARM_DESC(aq_itr_tx, "TX interrupt throttle rate");
35+
36+static unsigned int aq_itr_rx;
37+module_param_named(aq_itr_rx, aq_itr_rx, uint, 0644);
38+MODULE_PARM_DESC(aq_itr_rx, "RX interrupt throttle rate");
39+
2740 static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues)
2841 {
2942 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
@@ -61,9 +74,9 @@ static void aq_nic_cfg_init_defaults(struct aq_nic_s *self) · 31 unmodified lines
6174
6275 cfg->is_polling = AQ_CFG_IS_POLLING_DEF;
6376
64− cfg->is_interrupt_moderation = AQ_CFG_IS_INTERRUPT_MODERATION_DEF;
65− cfg->itr = cfg->is_interrupt_moderation ?
66− AQ_CFG_INTERRUPT_MODERATION_RATE_DEF : 0U;
77+ cfg->itr = aq_itr;
78+ cfg->tx_itr = aq_itr_tx;
79+ cfg->rx_itr = aq_itr_rx;
6780
6881 cfg->is_rss = AQ_CFG_IS_RSS_DEF;
6982 cfg->num_rss_queues = AQ_CFG_NUM_RSS_QUEUES_DEF;
@@ -126,10 +139,12 @@ static int aq_nic_update_link_status(struct aq_nic_s *self) · 56 unmodified lines
126139 if (err)
127140 return err;
128141
129− if (self->link_status.mbps != self->aq_hw->aq_link_status.mbps)
142+ if (self->link_status.mbps != self->aq_hw->aq_link_status.mbps) {
130143 pr_info("%s: link change old %d new %d\n",
131144 AQ_CFG_DRV_NAME, self->link_status.mbps,
132145 self->aq_hw->aq_link_status.mbps);
146+ aq_nic_update_interrupt_moderation_settings(self);
147+ }
133148
134149 self->link_status = self->aq_hw->aq_link_status;
135150 if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) {
@@ -164,8 +179,8 @@ static void aq_nic_service_timer_cb(unsigned long param) · 28 unmodified lines
164179 if (err)
165180 goto err_exit;
166181
167− self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,
168− self->aq_nic_cfg.is_interrupt_moderation);
182+ if (self->aq_hw_ops.hw_update_stats)
183+ self->aq_hw_ops.hw_update_stats(self->aq_hw);
169184
170185 memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));
171186 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
@@ -334,6 +349,7 @@ struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev) · 162 unmodified lines
334349 }
335350 if (netif_running(ndev))
336351 netif_tx_disable(ndev);
352+ netif_carrier_off(self->ndev);
337353
338354 for (self->aq_vecs = 0; self->aq_vecs < self->aq_nic_cfg.vecs;
339355 self->aq_vecs++) {
@@ -421,9 +437,8 @@ int aq_nic_start(struct aq_nic_s *self) · 81 unmodified lines
421437 if (err < 0)
422438 goto err_exit;
423439
424− err = self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,
425− self->aq_nic_cfg.is_interrupt_moderation);
426− if (err < 0)
440+ err = aq_nic_update_interrupt_moderation_settings(self);
441+ if (err)
427442 goto err_exit;
428443 setup_timer(&self->service_timer, &aq_nic_service_timer_cb,
429444 (unsigned long)self);
@@ -645,6 +660,11 @@ err_exit: · 215 unmodified lines
645660 return err;
646661 }
647662
663+int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self)
664+{
665+ return self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw);
666+}
667+
648668 int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags)
649669 {
650670 int err = 0;
@@ -899,6 +919,7 @@ int aq_nic_stop(struct aq_nic_s *self) · 248 unmodified lines
899919 unsigned int i = 0U;
900920
901921 netif_tx_disable(self->ndev);
922+ netif_carrier_off(self->ndev);
902923
903924 del_timer_sync(&self->service_timer);
904925
drivers/net/ethernet/aquantia/atlantic/aq_nic.h+3−1
@@ -40,6 +40,8 @@ struct aq_nic_cfg_s { · 39 unmodified lines
4040 u32 vecs; /* vecs==allocated irqs */
4141 u32 irq_type;
4242 u32 itr;
43+ u16 rx_itr;
44+ u16 tx_itr;
4345 u32 num_rss_queues;
4446 u32 mtu;
4547 u32 ucp_0x364;
@@ -49,7 +51,6 @@ struct aq_nic_cfg_s { · 3 unmodified lines
4951 u16 is_mc_list_enabled;
5052 u16 mc_list_count;
5153 bool is_autoneg;
52− bool is_interrupt_moderation;
5354 bool is_polling;
5455 bool is_rss;
5556 bool is_lro;
@@ -104,5 +105,6 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self, · 48 unmodified lines
104105 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
105106 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
106107 int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
108+int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
107109
108110 #endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c+10−4
@@ -85,6 +85,7 @@ int aq_pci_func_init(struct aq_pci_func_s *self) · 84 unmodified lines
8585 int err = 0;
8686 unsigned int bar = 0U;
8787 unsigned int port = 0U;
88+ unsigned int numvecs = 0U;
8889
8990 err = pci_enable_device(self->pdev);
9091 if (err < 0)
@@ -142,10 +143,12 @@ int aq_pci_func_init(struct aq_pci_func_s *self) · 51 unmodified lines
142143 }
143144 }
144145
145− /*enable interrupts */
146+ numvecs = min((u8)AQ_CFG_VECS_DEF, self->aq_hw_caps.msix_irqs);
147+ numvecs = min(numvecs, num_online_cpus());
148+
149+ /* enable interrupts */
146150 #if !AQ_CFG_FORCE_LEGACY_INT
147− err = pci_alloc_irq_vectors(self->pdev, self->aq_hw_caps.msix_irqs,
148− self->aq_hw_caps.msix_irqs, PCI_IRQ_MSIX);
151+ err = pci_alloc_irq_vectors(self->pdev, numvecs, numvecs, PCI_IRQ_MSIX);
149152
150153 if (err < 0) {
151154 err = pci_alloc_irq_vectors(self->pdev, 1, 1,
@@ -153,7 +156,7 @@ int aq_pci_func_init(struct aq_pci_func_s *self) · 1 unmodified line
153156 if (err < 0)
154157 goto err_exit;
155158 }
156−#endif
159+#endif /* AQ_CFG_FORCE_LEGACY_INT */
157160
158161 /* net device init */
159162 for (port = 0; port < self->ports; ++port) {
@@ -265,6 +268,9 @@ void aq_pci_func_free(struct aq_pci_func_s *self) · 105 unmodified lines
265268 aq_nic_ndev_free(self->port[port]);
266269 }
267270
271+ if (self->mmio)
272+ iounmap(self->mmio);
273+
268274 kfree(self);
269275
270276 err_exit:;
drivers/net/ethernet/aquantia/atlantic/aq_vec.c+3−0
@@ -373,8 +373,11 @@ int aq_vec_get_sw_stats(struct aq_vec_s *self, u64 *data, unsigned int *p_count) · 372 unmodified lines
373373 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
374374 aq_vec_add_stats(self, &stats_rx, &stats_tx);
375375
376+ /* This data should mimic aq_ethtool_queue_stat_names structure
377+ */
376378 data[count] += stats_rx.packets;
377379 data[++count] += stats_tx.packets;
380+ data[++count] += stats_tx.queue_restarts;
378381 data[++count] += stats_rx.jumbo_packets;
379382 data[++count] += stats_rx.lro_packets;
380383 data[++count] += stats_rx.errors;
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c+10−11
@@ -765,24 +765,23 @@ err_exit: · 764 unmodified lines
765765 return err;
766766 }
767767
768−static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self,
769− bool itr_enabled)
768+static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self)
770769 {
771770 unsigned int i = 0U;
771+ u32 itr_rx;
772772
773− if (itr_enabled && self->aq_nic_cfg->itr) {
774− if (self->aq_nic_cfg->itr != 0xFFFFU) {
773+ if (self->aq_nic_cfg->itr) {
774+ if (self->aq_nic_cfg->itr != AQ_CFG_INTERRUPT_MODERATION_AUTO) {
775775 u32 itr_ = (self->aq_nic_cfg->itr >> 1);
776776
777777 itr_ = min(AQ_CFG_IRQ_MASK, itr_);
778778
779− PHAL_ATLANTIC_A0->itr_rx = 0x80000000U |
780− (itr_ << 0x10);
779+ itr_rx = 0x80000000U | (itr_ << 0x10);
781780 } else {
782781 u32 n = 0xFFFFU & aq_hw_read_reg(self, 0x00002A00U);
783782
784783 if (n < self->aq_link_status.mbps) {
785− PHAL_ATLANTIC_A0->itr_rx = 0U;
784+ itr_rx = 0U;
786785 } else {
787786 static unsigned int hw_timers_tbl_[] = {
788787 0x01CU, /* 10Gbit */
@@ -797,8 +796,7 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self, · 8 unmodified lines
797796 hw_atl_utils_mbps_2_speed_index(
798797 self->aq_link_status.mbps);
799798
800− PHAL_ATLANTIC_A0->itr_rx =
801− 0x80000000U |
799+ itr_rx = 0x80000000U |
802800 (hw_timers_tbl_[speed_index] << 0x10U);
803801 }
804802
@@ -806,11 +804,11 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self, · 1 unmodified line
806804 aq_hw_write_reg(self, 0x00002A00U, 0x8D000000U);
807805 }
808806 } else {
809− PHAL_ATLANTIC_A0->itr_rx = 0U;
807+ itr_rx = 0U;
810808 }
811809
812810 for (i = HW_ATL_A0_RINGS_MAX; i--;)
813− reg_irq_thr_set(self, PHAL_ATLANTIC_A0->itr_rx, i);
811+ reg_irq_thr_set(self, itr_rx, i);
814812
815813 return aq_hw_err_from_flags(self);
816814 }
@@ -885,6 +883,7 @@ static struct aq_hw_ops hw_atl_ops_ = { · 68 unmodified lines
885883 .hw_rss_set = hw_atl_a0_hw_rss_set,
886884 .hw_rss_hash_set = hw_atl_a0_hw_rss_hash_set,
887885 .hw_get_regs = hw_atl_utils_hw_get_regs,
886+ .hw_update_stats = hw_atl_utils_update_stats,
888887 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
889888 .hw_get_fw_version = hw_atl_utils_get_fw_version,
890889 };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c+49−40
@@ -788,39 +788,45 @@ err_exit: · 787 unmodified lines
788788 return err;
789789 }
790790
791−static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self,
792− bool itr_enabled)
791+static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self)
793792 {
794793 unsigned int i = 0U;
794+ u32 itr_tx = 2U;
795+ u32 itr_rx = 2U;
795796
796− if (itr_enabled && self->aq_nic_cfg->itr) {
797+ switch (self->aq_nic_cfg->itr) {
798+ case AQ_CFG_INTERRUPT_MODERATION_ON:
799+ case AQ_CFG_INTERRUPT_MODERATION_AUTO:
797800 tdm_tx_desc_wr_wb_irq_en_set(self, 0U);
798801 tdm_tdm_intr_moder_en_set(self, 1U);
799802 rdm_rx_desc_wr_wb_irq_en_set(self, 0U);
800803 rdm_rdm_intr_moder_en_set(self, 1U);
801804
802− PHAL_ATLANTIC_B0->itr_tx = 2U;
803− PHAL_ATLANTIC_B0->itr_rx = 2U;
805+ if (self->aq_nic_cfg->itr == AQ_CFG_INTERRUPT_MODERATION_ON) {
806+ /* HW timers are in 2us units */
807+ int tx_max_timer = self->aq_nic_cfg->tx_itr / 2;
808+ int tx_min_timer = tx_max_timer / 2;
804809
805− if (self->aq_nic_cfg->itr != 0xFFFFU) {
806− unsigned int max_timer = self->aq_nic_cfg->itr / 2U;
807− unsigned int min_timer = self->aq_nic_cfg->itr / 32U;
810+ int rx_max_timer = self->aq_nic_cfg->rx_itr / 2;
811+ int rx_min_timer = rx_max_timer / 2;
808812
809− max_timer = min(0x1FFU, max_timer);
810− min_timer = min(0xFFU, min_timer);
813+ tx_max_timer = min(HW_ATL_INTR_MODER_MAX, tx_max_timer);
814+ tx_min_timer = min(HW_ATL_INTR_MODER_MIN, tx_min_timer);
815+ rx_max_timer = min(HW_ATL_INTR_MODER_MAX, rx_max_timer);
816+ rx_min_timer = min(HW_ATL_INTR_MODER_MIN, rx_min_timer);
811817
812− PHAL_ATLANTIC_B0->itr_tx |= min_timer << 0x8U;
813− PHAL_ATLANTIC_B0->itr_tx |= max_timer << 0x10U;
814− PHAL_ATLANTIC_B0->itr_rx |= min_timer << 0x8U;
815− PHAL_ATLANTIC_B0->itr_rx |= max_timer << 0x10U;
818+ itr_tx |= tx_min_timer << 0x8U;
819+ itr_tx |= tx_max_timer << 0x10U;
820+ itr_rx |= rx_min_timer << 0x8U;
821+ itr_rx |= rx_max_timer << 0x10U;
816822 } else {
817823 static unsigned int hw_atl_b0_timers_table_tx_[][2] = {
818− {0xffU, 0xffU}, /* 10Gbit */
819− {0xffU, 0x1ffU}, /* 5Gbit */
820− {0xffU, 0x1ffU}, /* 5Gbit 5GS */
821− {0xffU, 0x1ffU}, /* 2.5Gbit */
822− {0xffU, 0x1ffU}, /* 1Gbit */
823− {0xffU, 0x1ffU}, /* 100Mbit */
824+ {0xfU, 0xffU}, /* 10Gbit */
825+ {0xfU, 0x1ffU}, /* 5Gbit */
826+ {0xfU, 0x1ffU}, /* 5Gbit 5GS */
827+ {0xfU, 0x1ffU}, /* 2.5Gbit */
828+ {0xfU, 0x1ffU}, /* 1Gbit */
829+ {0xfU, 0x1ffU}, /* 100Mbit */
824830 };
825831
826832 static unsigned int hw_atl_b0_timers_table_rx_[][2] = {
@@ -836,34 +842,36 @@ static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self, · 9 unmodified lines
836842 hw_atl_utils_mbps_2_speed_index(
837843 self->aq_link_status.mbps);
838844
839− PHAL_ATLANTIC_B0->itr_tx |=
840− hw_atl_b0_timers_table_tx_[speed_index]
841− [0] << 0x8U; /* set min timer value */
842− PHAL_ATLANTIC_B0->itr_tx |=
843− hw_atl_b0_timers_table_tx_[speed_index]
844− [1] << 0x10U; /* set max timer value */
845−
846− PHAL_ATLANTIC_B0->itr_rx |=
847− hw_atl_b0_timers_table_rx_[speed_index]
848− [0] << 0x8U; /* set min timer value */
849− PHAL_ATLANTIC_B0->itr_rx |=
850− hw_atl_b0_timers_table_rx_[speed_index]
851− [1] << 0x10U; /* set max timer value */
845+ /* Update user visible ITR settings */
846+ self->aq_nic_cfg->tx_itr = hw_atl_b0_timers_table_tx_
847+ [speed_index][1] * 2;
848+ self->aq_nic_cfg->rx_itr = hw_atl_b0_timers_table_rx_
849+ [speed_index][1] * 2;
850+
851+ itr_tx |= hw_atl_b0_timers_table_tx_
852+ [speed_index][0] << 0x8U;
853+ itr_tx |= hw_atl_b0_timers_table_tx_
854+ [speed_index][1] << 0x10U;
855+
856+ itr_rx |= hw_atl_b0_timers_table_rx_
857+ [speed_index][0] << 0x8U;
858+ itr_rx |= hw_atl_b0_timers_table_rx_
859+ [speed_index][1] << 0x10U;
852860 }
853− } else {
861+ break;
862+ case AQ_CFG_INTERRUPT_MODERATION_OFF:
854863 tdm_tx_desc_wr_wb_irq_en_set(self, 1U);
855864 tdm_tdm_intr_moder_en_set(self, 0U);
856865 rdm_rx_desc_wr_wb_irq_en_set(self, 1U);
857866 rdm_rdm_intr_moder_en_set(self, 0U);
858− PHAL_ATLANTIC_B0->itr_tx = 0U;
859− PHAL_ATLANTIC_B0->itr_rx = 0U;
867+ itr_tx = 0U;
868+ itr_rx = 0U;
869+ break;
860870 }
861871
862872 for (i = HW_ATL_B0_RINGS_MAX; i--;) {
863− reg_tx_intr_moder_ctrl_set(self,
864− PHAL_ATLANTIC_B0->itr_tx, i);
865− reg_rx_intr_moder_ctrl_set(self,
866− PHAL_ATLANTIC_B0->itr_rx, i);
873+ reg_tx_intr_moder_ctrl_set(self, itr_tx, i);
874+ reg_rx_intr_moder_ctrl_set(self, itr_rx, i);
867875 }
868876
869877 return aq_hw_err_from_flags(self);
@@ -939,6 +947,7 @@ static struct aq_hw_ops hw_atl_ops_ = { · 69 unmodified lines
939947 .hw_rss_set = hw_atl_b0_hw_rss_set,
940948 .hw_rss_hash_set = hw_atl_b0_hw_rss_hash_set,
941949 .hw_get_regs = hw_atl_utils_hw_get_regs,
950+ .hw_update_stats = hw_atl_utils_update_stats,
942951 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
943952 .hw_get_fw_version = hw_atl_utils_get_fw_version,
944953 };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h+3−0
@@ -139,6 +139,9 @@ · 138 unmodified lines
139139
140140 #define HW_ATL_B0_FW_VER_EXPECTED 0x01050006U
141141
142+#define HW_ATL_INTR_MODER_MAX 0x1FF
143+#define HW_ATL_INTR_MODER_MIN 0xFF
144+
142145 /* Hardware tx descriptor */
143146 struct __packed hw_atl_txd_s {
144147 u64 buf_addr;
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c+55−14
@@ -255,6 +255,15 @@ err_exit: · 254 unmodified lines
255255 return err;
256256 }
257257
258+int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
259+ struct hw_aq_atl_utils_mbox_header *pmbox)
260+{
261+ return hw_atl_utils_fw_downld_dwords(self,
262+ PHAL_ATLANTIC->mbox_addr,
263+ (u32 *)(void *)pmbox,
264+ sizeof(*pmbox) / sizeof(u32));
265+}
266+
258267 void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
259268 struct hw_aq_atl_utils_mbox *pmbox)
260269 {
@@ -267,9 +276,6 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, · 6 unmodified lines
267276 if (err < 0)
268277 goto err_exit;
269278
270− if (pmbox != &PHAL_ATLANTIC->mbox)
271− memcpy(pmbox, &PHAL_ATLANTIC->mbox, sizeof(*pmbox));
272−
273279 if (IS_CHIP_FEATURE(REVISION_A0)) {
274280 unsigned int mtu = self->aq_nic_cfg ?
275281 self->aq_nic_cfg->mtu : 1514U;
@@ -299,17 +305,17 @@ void hw_atl_utils_mpi_set(struct aq_hw_s *self, · 23 unmodified lines
299305 {
300306 int err = 0;
301307 u32 transaction_id = 0;
308+ struct hw_aq_atl_utils_mbox_header mbox;
302309
303310 if (state == MPI_RESET) {
304− hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox);
311+ hw_atl_utils_mpi_read_mbox(self, &mbox);
305312
306− transaction_id = PHAL_ATLANTIC->mbox.transaction_id;
313+ transaction_id = mbox.transaction_id;
307314
308315 AQ_HW_WAIT_FOR(transaction_id !=
309− (hw_atl_utils_mpi_read_stats
310− (self, &PHAL_ATLANTIC->mbox),
311− PHAL_ATLANTIC->mbox.transaction_id),
312− 1000U, 100U);
316+ (hw_atl_utils_mpi_read_mbox(self, &mbox),
317+ mbox.transaction_id),
318+ 1000U, 100U);
313319 if (err < 0)
314320 goto err_exit;
315321 }
@@ -492,16 +498,51 @@ int hw_atl_utils_hw_set_power(struct aq_hw_s *self, · 176 unmodified lines
492498 return 0;
493499 }
494500
501+int hw_atl_utils_update_stats(struct aq_hw_s *self)
502+{
503+ struct hw_atl_s *hw_self = PHAL_ATLANTIC;
504+ struct hw_aq_atl_utils_mbox mbox;
505+
506+ if (!self->aq_link_status.mbps)
507+ return 0;
508+
509+ hw_atl_utils_mpi_read_stats(self, &mbox);
510+
511+#define AQ_SDELTA(_N_) (hw_self->curr_stats._N_ += \
512+ mbox.stats._N_ - hw_self->last_stats._N_)
513+
514+ AQ_SDELTA(uprc);
515+ AQ_SDELTA(mprc);
516+ AQ_SDELTA(bprc);
517+ AQ_SDELTA(erpt);
518+
519+ AQ_SDELTA(uptc);
520+ AQ_SDELTA(mptc);
521+ AQ_SDELTA(bptc);
522+ AQ_SDELTA(erpr);
523+
524+ AQ_SDELTA(ubrc);
525+ AQ_SDELTA(ubtc);
526+ AQ_SDELTA(mbrc);
527+ AQ_SDELTA(mbtc);
528+ AQ_SDELTA(bbrc);
529+ AQ_SDELTA(bbtc);
530+ AQ_SDELTA(dpc);
531+
532+#undef AQ_SDELTA
533+
534+ memcpy(&hw_self->last_stats, &mbox.stats, sizeof(mbox.stats));
535+
536+ return 0;
537+}
538+
495539 int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
496540 u64 *data, unsigned int *p_count)
497541 {
498− struct hw_atl_stats_s *stats = NULL;
542+ struct hw_atl_s *hw_self = PHAL_ATLANTIC;
543+ struct hw_atl_stats_s *stats = &hw_self->curr_stats;
499544 int i = 0;
500545
501− hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox);
502−
503− stats = &PHAL_ATLANTIC->mbox.stats;
504−
505546 data[i] = stats->uprc + stats->mprc + stats->bprc;
506547 data[++i] = stats->uprc;
507548 data[++i] = stats->mprc;
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h+13−5
@@ -115,19 +115,22 @@ struct __packed hw_aq_atl_utils_fw_rpc { · 114 unmodified lines
115115 };
116116 };
117117
118−struct __packed hw_aq_atl_utils_mbox {
118+struct __packed hw_aq_atl_utils_mbox_header {
119119 u32 version;
120120 u32 transaction_id;
121− int error;
121+ u32 error;
122+};
123+
124+struct __packed hw_aq_atl_utils_mbox {
125+ struct hw_aq_atl_utils_mbox_header header;
122126 struct hw_atl_stats_s stats;
123127 };
124128
125129 struct __packed hw_atl_s {
126130 struct aq_hw_s base;
127− struct hw_aq_atl_utils_mbox mbox;
131+ struct hw_atl_stats_s last_stats;
132+ struct hw_atl_stats_s curr_stats;
128133 u64 speed;
129− u32 itr_tx;
130− u32 itr_rx;
131134 unsigned int chip_features;
132135 u32 fw_ver_actual;
133136 atomic_t dpc;
@@ -170,6 +173,9 @@ enum hal_atl_utils_fw_state_e { · 36 unmodified lines
170173
171174 void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);
172175
176+int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
177+ struct hw_aq_atl_utils_mbox_header *pmbox);
178+
173179 void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
174180 struct hw_aq_atl_utils_mbox *pmbox);
175181
@@ -199,6 +205,8 @@ int hw_atl_utils_hw_deinit(struct aq_hw_s *self); · 23 unmodified lines
199205
200206 int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version);
201207
208+int hw_atl_utils_update_stats(struct aq_hw_s *self);
209+
202210 int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
203211 u64 *data,
204212 unsigned int *p_count);
drivers/net/ethernet/broadcom/bnxt/bnxt.c+73−26
@@ -214,6 +214,8 @@ static const u16 bnxt_async_events_arr[] = { · 213 unmodified lines
214214 ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,
215215 };
216216
217+static struct workqueue_struct *bnxt_pf_wq;
218+
217219 static bool bnxt_vf_pciid(enum board_idx idx)
218220 {
219221 return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF);
@@ -1024,12 +1026,28 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_napi *bnapi, · 804 unmodified lines
10241026 return 0;
10251027 }
10261028
1029+static void bnxt_queue_sp_work(struct bnxt *bp)
1030+{
1031+ if (BNXT_PF(bp))
1032+ queue_work(bnxt_pf_wq, &bp->sp_task);
1033+ else
1034+ schedule_work(&bp->sp_task);
1035+}
1036+
1037+static void bnxt_cancel_sp_work(struct bnxt *bp)
1038+{
1039+ if (BNXT_PF(bp))
1040+ flush_workqueue(bnxt_pf_wq);
1041+ else
1042+ cancel_work_sync(&bp->sp_task);
1043+}
1044+
10271045 static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
10281046 {
10291047 if (!rxr->bnapi->in_reset) {
10301048 rxr->bnapi->in_reset = true;
10311049 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
1032− schedule_work(&bp->sp_task);
1050+ bnxt_queue_sp_work(bp);
10331051 }
10341052 rxr->rx_next_cons = 0xffff;
10351053 }
@@ -1717,7 +1735,7 @@ static int bnxt_async_event_process(struct bnxt *bp, · 681 unmodified lines
17171735 default:
17181736 goto async_event_process_exit;
17191737 }
1720− schedule_work(&bp->sp_task);
1738+ bnxt_queue_sp_work(bp);
17211739 async_event_process_exit:
17221740 bnxt_ulp_async_events(bp, cmpl);
17231741 return 0;
@@ -1751,7 +1769,7 @@ static int bnxt_hwrm_handler(struct bnxt *bp, struct tx_cmp *txcmp) · 27 unmodified lines
17511769
17521770 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap);
17531771 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event);
1754− schedule_work(&bp->sp_task);
1772+ bnxt_queue_sp_work(bp);
17551773 break;
17561774
17571775 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
@@ -3448,6 +3466,12 @@ int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout) · 1690 unmodified lines
34483466 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false);
34493467 }
34503468
3469+int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len,
3470+ int timeout)
3471+{
3472+ return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, true);
3473+}
3474+
34513475 int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
34523476 {
34533477 int rc;
@@ -6327,7 +6351,9 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) · 2873 unmodified lines
63276351 }
63286352
63296353 if (link_re_init) {
6354+ mutex_lock(&bp->link_lock);
63306355 rc = bnxt_update_phy_setting(bp);
6356+ mutex_unlock(&bp->link_lock);
63316357 if (rc)
63326358 netdev_warn(bp->dev, "failed to update phy settings\n");
63336359 }
@@ -6647,7 +6673,7 @@ static void bnxt_set_rx_mode(struct net_device *dev) · 313 unmodified lines
66476673 vnic->rx_mask = mask;
66486674
66496675 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event);
6650− schedule_work(&bp->sp_task);
6676+ bnxt_queue_sp_work(bp);
66516677 }
66526678 }
66536679
@@ -6920,7 +6946,7 @@ static void bnxt_tx_timeout(struct net_device *dev) · 266 unmodified lines
69206946
69216947 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n");
69226948 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
6923− schedule_work(&bp->sp_task);
6949+ bnxt_queue_sp_work(bp);
69246950 }
69256951
69266952 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -6952,7 +6978,7 @@ static void bnxt_timer(unsigned long data) · 25 unmodified lines
69526978 if (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) &&
69536979 bp->stats_coal_ticks) {
69546980 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);
6955− schedule_work(&bp->sp_task);
6981+ bnxt_queue_sp_work(bp);
69566982 }
69576983 bnxt_restart_timer:
69586984 mod_timer(&bp->timer, jiffies + bp->current_interval);
@@ -7025,30 +7051,28 @@ static void bnxt_sp_task(struct work_struct *work) · 66 unmodified lines
70257051 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))
70267052 bnxt_hwrm_port_qstats(bp);
70277053
7028− /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7029− * must be the last functions to be called before exiting.
7030− */
70317054 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
7032− int rc = 0;
7055+ int rc;
70337056
7057+ mutex_lock(&bp->link_lock);
70347058 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
70357059 &bp->sp_event))
70367060 bnxt_hwrm_phy_qcaps(bp);
70377061
7038− bnxt_rtnl_lock_sp(bp);
7039− if (test_bit(BNXT_STATE_OPEN, &bp->state))
7040− rc = bnxt_update_link(bp, true);
7041− bnxt_rtnl_unlock_sp(bp);
7062+ rc = bnxt_update_link(bp, true);
7063+ mutex_unlock(&bp->link_lock);
70427064 if (rc)
70437065 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
70447066 rc);
70457067 }
70467068 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {
7047− bnxt_rtnl_lock_sp(bp);
7048− if (test_bit(BNXT_STATE_OPEN, &bp->state))
7049− bnxt_get_port_module_status(bp);
7050− bnxt_rtnl_unlock_sp(bp);
7069+ mutex_lock(&bp->link_lock);
7070+ bnxt_get_port_module_status(bp);
7071+ mutex_unlock(&bp->link_lock);
70517072 }
7073+ /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7074+ * must be the last functions to be called before exiting.
7075+ */
70527076 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
70537077 bnxt_reset(bp, false);
70547078
@@ -7433,7 +7457,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, · 378 unmodified lines
74337457 spin_unlock_bh(&bp->ntp_fltr_lock);
74347458
74357459 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event);
7436− schedule_work(&bp->sp_task);
7460+ bnxt_queue_sp_work(bp);
74377461
74387462 return new_fltr->sw_id;
74397463
@@ -7516,7 +7540,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev, · 76 unmodified lines
75167540 if (bp->vxlan_port_cnt == 1) {
75177541 bp->vxlan_port = ti->port;
75187542 set_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event);
7519− schedule_work(&bp->sp_task);
7543+ bnxt_queue_sp_work(bp);
75207544 }
75217545 break;
75227546 case UDP_TUNNEL_TYPE_GENEVE:
@@ -7533,7 +7557,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev, · 10 unmodified lines
75337557 return;
75347558 }
75357559
7536− schedule_work(&bp->sp_task);
7560+ bnxt_queue_sp_work(bp);
75377561 }
75387562
75397563 static void bnxt_udp_tunnel_del(struct net_device *dev,
@@ -7572,7 +7596,7 @@ static void bnxt_udp_tunnel_del(struct net_device *dev, · 32 unmodified lines
75727596 return;
75737597 }
75747598
7575− schedule_work(&bp->sp_task);
7599+ bnxt_queue_sp_work(bp);
75767600 }
75777601
75787602 static int bnxt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
@@ -7720,7 +7744,7 @@ static void bnxt_remove_one(struct pci_dev *pdev) · 141 unmodified lines
77207744 pci_disable_pcie_error_reporting(pdev);
77217745 unregister_netdev(dev);
77227746 bnxt_shutdown_tc(bp);
7723− cancel_work_sync(&bp->sp_task);
7747+ bnxt_cancel_sp_work(bp);
77247748 bp->sp_event = 0;
77257749
77267750 bnxt_clear_int_mode(bp);
@@ -7748,6 +7772,7 @@ static int bnxt_probe_phy(struct bnxt *bp) · 21 unmodified lines
77487772 rc);
77497773 return rc;
77507774 }
7775+ mutex_init(&bp->link_lock);
77517776
77527777 rc = bnxt_update_link(bp, false);
77537778 if (rc) {
@@ -7946,7 +7971,7 @@ static void bnxt_parse_log_pcie_link(struct bnxt *bp) · 192 unmodified lines
79467971 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
79477972 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
79487973
7949− if (pcie_get_minimum_link(bp->pdev, &speed, &width) ||
7974+ if (pcie_get_minimum_link(pci_physfn(bp->pdev), &speed, &width) ||
79507975 speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)
79517976 netdev_info(bp->dev, "Failed to determine PCIe Link Info\n");
79527977 else
@@ -8138,8 +8163,17 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 185 unmodified lines
81388163 else
81398164 device_set_wakeup_capable(&pdev->dev, false);
81408165
8141− if (BNXT_PF(bp))
8166+ if (BNXT_PF(bp)) {
8167+ if (!bnxt_pf_wq) {
8168+ bnxt_pf_wq =
8169+ create_singlethread_workqueue("bnxt_pf_wq");
8170+ if (!bnxt_pf_wq) {
8171+ dev_err(&pdev->dev, "Unable to create workqueue.\n");
8172+ goto init_err_pci_clean;
8173+ }
8174+ }
81428175 bnxt_init_tc(bp);
8176+ }
81438177
81448178 rc = register_netdev(dev);
81458179 if (rc)
@@ -8375,4 +8409,17 @@ static struct pci_driver bnxt_pci_driver = { · 229 unmodified lines
83758409 #endif
83768410 };
83778411
8378−module_pci_driver(bnxt_pci_driver);
8412+static int __init bnxt_init(void)
8413+{
8414+ return pci_register_driver(&bnxt_pci_driver);
8415+}
8416+
8417+static void __exit bnxt_exit(void)
8418+{
8419+ pci_unregister_driver(&bnxt_pci_driver);
8420+ if (bnxt_pf_wq)
8421+ destroy_workqueue(bnxt_pf_wq);
8422+}
8423+
8424+module_init(bnxt_init);
8425+module_exit(bnxt_exit);
drivers/net/ethernet/broadcom/bnxt/bnxt.h+5−0
@@ -1290,6 +1290,10 @@ struct bnxt { · 1289 unmodified lines
12901290 unsigned long *ntp_fltr_bmap;
12911291 int ntp_fltr_count;
12921292
1293+ /* To protect link related settings during link changes and
1294+ * ethtool settings changes.
1295+ */
1296+ struct mutex link_lock;
12931297 struct bnxt_link_info link_info;
12941298 struct ethtool_eee eee;
12951299 u32 lpi_tmr_lo;
@@ -1358,6 +1362,7 @@ void bnxt_set_ring_params(struct bnxt *); · 62 unmodified lines
13581362 int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
13591363 void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
13601364 int _hwrm_send_message(struct bnxt *, void *, u32, int);
1365+int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
13611366 int hwrm_send_message(struct bnxt *, void *, u32, int);
13621367 int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
13631368 int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c+18−5
@@ -50,7 +50,9 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 49 unmodified lines
5050
5151 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1);
5252 req.flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN);
53− rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
53+
54+ mutex_lock(&bp->hwrm_cmd_lock);
55+ rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5456 if (!rc) {
5557 u8 *pri2cos = &resp->pri0_cos_queue_id;
5658 int i, j;
@@ -66,6 +68,7 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 9 unmodified lines
6668 }
6769 }
6870 }
71+ mutex_unlock(&bp->hwrm_cmd_lock);
6972 return rc;
7073 }
7174
@@ -119,9 +122,13 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 47 unmodified lines
119122 int rc, i;
120123
121124 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_QCFG, -1, -1);
122− rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
123− if (rc)
125+
126+ mutex_lock(&bp->hwrm_cmd_lock);
127+ rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
128+ if (rc) {
129+ mutex_unlock(&bp->hwrm_cmd_lock);
124130 return rc;
131+ }
125132
126133 data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);
127134 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) {
@@ -143,6 +150,7 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 15 unmodified lines
143150 }
144151 }
145152 }
153+ mutex_unlock(&bp->hwrm_cmd_lock);
146154 return 0;
147155 }
148156
@@ -240,12 +248,17 @@ static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc) · 91 unmodified lines
240248 int rc;
241249
242250 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_QCFG, -1, -1);
243− rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
244− if (rc)
251+
252+ mutex_lock(&bp->hwrm_cmd_lock);
253+ rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
254+ if (rc) {
255+ mutex_unlock(&bp->hwrm_cmd_lock);
245256 return rc;
257+ }
246258
247259 pri_mask = le32_to_cpu(resp->flags);
248260 pfc->pfc_en = pri_mask;
261+ mutex_unlock(&bp->hwrm_cmd_lock);
249262 return 0;
250263 }
251264
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c+7−1
@@ -1052,6 +1052,7 @@ static int bnxt_get_link_ksettings(struct net_device *dev, · 1051 unmodified lines
10521052 u32 ethtool_speed;
10531053
10541054 ethtool_link_ksettings_zero_link_mode(lk_ksettings, supported);
1055+ mutex_lock(&bp->link_lock);
10551056 bnxt_fw_to_ethtool_support_spds(link_info, lk_ksettings);
10561057
10571058 ethtool_link_ksettings_zero_link_mode(lk_ksettings, advertising);
@@ -1099,6 +1100,7 @@ static int bnxt_get_link_ksettings(struct net_device *dev, · 41 unmodified lines
10991100 base->port = PORT_FIBRE;
11001101 }
11011102 base->phy_address = link_info->phy_addr;
1103+ mutex_unlock(&bp->link_lock);
11021104
11031105 return 0;
11041106 }
@@ -1190,6 +1192,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev, · 85 unmodified lines
11901192 if (!BNXT_SINGLE_PF(bp))
11911193 return -EOPNOTSUPP;
11921194
1195+ mutex_lock(&bp->link_lock);
11931196 if (base->autoneg == AUTONEG_ENABLE) {
11941197 BNXT_ETHTOOL_TO_FW_SPDS(fw_advertising, lk_ksettings,
11951198 advertising);
@@ -1234,6 +1237,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev, · 38 unmodified lines
12341237 rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);
12351238
12361239 set_setting_exit:
1240+ mutex_unlock(&bp->link_lock);
12371241 return rc;
12381242 }
12391243
@@ -1805,7 +1809,8 @@ static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal, · 565 unmodified lines
18051809 req.dir_ordinal = cpu_to_le16(ordinal);
18061810 req.dir_ext = cpu_to_le16(ext);
18071811 req.opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ;
1808− rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
1812+ mutex_lock(&bp->hwrm_cmd_lock);
1813+ rc = _hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
18091814 if (rc == 0) {
18101815 if (index)
18111816 *index = le16_to_cpu(output->dir_idx);
@@ -1814,6 +1819,7 @@ static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal, · 2 unmodified lines
18141819 if (data_length)
18151820 *data_length = le32_to_cpu(output->dir_data_length);
18161821 }
1822+ mutex_unlock(&bp->hwrm_cmd_lock);
18171823 return rc;
18181824 }
18191825
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c+9−2
@@ -502,6 +502,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) · 501 unmodified lines
502502 int rc = 0, vfs_supported;
503503 int min_rx_rings, min_tx_rings, min_rss_ctxs;
504504 int tx_ok = 0, rx_ok = 0, rss_ok = 0;
505+ int avail_cp, avail_stat;
505506
506507 /* Check if we can enable requested num of vf's. At a mininum
507508 * we require 1 RX 1 TX rings for each VF. In this minimum conf
@@ -509,6 +510,10 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) · 1 unmodified line
509510 */
510511 vfs_supported = *num_vfs;
511512
513+ avail_cp = bp->pf.max_cp_rings - bp->cp_nr_rings;
514+ avail_stat = bp->pf.max_stat_ctxs - bp->num_stat_ctxs;
515+ avail_cp = min_t(int, avail_cp, avail_stat);
516+
512517 while (vfs_supported) {
513518 min_rx_rings = vfs_supported;
514519 min_tx_rings = vfs_supported;
@@ -523,10 +528,12 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) · 8 unmodified lines
523528 min_rx_rings)
524529 rx_ok = 1;
525530 }
526− if (bp->pf.max_vnics - bp->nr_vnics < min_rx_rings)
531+ if (bp->pf.max_vnics - bp->nr_vnics < min_rx_rings ||
532+ avail_cp < min_rx_rings)
527533 rx_ok = 0;
528534
529− if (bp->pf.max_tx_rings - bp->tx_nr_rings >= min_tx_rings)
535+ if (bp->pf.max_tx_rings - bp->tx_nr_rings >= min_tx_rings &&
536+ avail_cp >= min_tx_rings)
530537 tx_ok = 1;
531538
532539 if (bp->pf.max_rsscos_ctxs - bp->rsscos_nr_ctxs >= min_rss_ctxs)
drivers/net/ethernet/cavium/liquidio/lio_main.c+1−1
@@ -1847,7 +1847,7 @@ static int liquidio_ptp_settime(struct ptp_clock_info *ptp, · 1846 unmodified lines
18471847 struct lio *lio = container_of(ptp, struct lio, ptp_info);
18481848 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;
18491849
1850− ns = timespec_to_ns(ts);
1850+ ns = timespec64_to_ns(ts);
18511851
18521852 spin_lock_irqsave(&lio->ptp_lock, flags);
18531853 lio_pci_writeq(oct, ns, CN6XXX_MIO_PTP_CLOCK_HI);
drivers/net/ethernet/ibm/ibmvnic.c+8−8
@@ -1093,11 +1093,12 @@ static int build_hdr_data(u8 hdr_field, struct sk_buff *skb, · 1092 unmodified lines
10931093 * places them in a descriptor array, scrq_arr
10941094 */
10951095
1096−static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
1097− union sub_crq *scrq_arr)
1096+static int create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
1097+ union sub_crq *scrq_arr)
10981098 {
10991099 union sub_crq hdr_desc;
11001100 int tmp_len = len;
1101+ int num_descs = 0;
11011102 u8 *data, *cur;
11021103 int tmp;
11031104
@@ -1126,7 +1127,10 @@ static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len, · 22 unmodified lines
11261127 tmp_len -= tmp;
11271128 *scrq_arr = hdr_desc;
11281129 scrq_arr++;
1130+ num_descs++;
11291131 }
1132+
1133+ return num_descs;
11301134 }
11311135
11321136 /**
@@ -1144,16 +1148,12 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff *txbuff, · 11 unmodified lines
11441148 int *num_entries, u8 hdr_field)
11451149 {
11461150 int hdr_len[3] = {0, 0, 0};
1147− int tot_len, len;
1151+ int tot_len;
11481152 u8 *hdr_data = txbuff->hdr_data;
11491153
11501154 tot_len = build_hdr_data(hdr_field, txbuff->skb, hdr_len,
11511155 txbuff->hdr_data);
1152− len = tot_len;
1153− len -= 24;
1154− if (len > 0)
1155− num_entries += len % 29 ? len / 29 + 1 : len / 29;
1156− create_hdr_descs(hdr_field, hdr_data, tot_len, hdr_len,
1156+ *num_entries += create_hdr_descs(hdr_field, hdr_data, tot_len, hdr_len,
11571157 txbuff->indir_arr + 1);
11581158 }
11591159
drivers/net/ethernet/intel/i40e/i40e_nvm.c+1−1
@@ -298,7 +298,7 @@ static i40e_status i40e_read_nvm_word_aq(struct i40e_hw *hw, u16 offset, · 297 unmodified lines
298298 }
299299
300300 /**
301− * __i40e_read_nvm_word - Reads nvm word, assumes called does the locking
301+ * __i40e_read_nvm_word - Reads nvm word, assumes caller does the locking
302302 * @hw: pointer to the HW structure
303303 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
304304 * @data: word read from the Shadow RAM
drivers/net/ethernet/intel/i40e/i40e_txrx.c+36−27
@@ -1037,6 +1037,32 @@ reset_latency: · 1036 unmodified lines
10371037 return false;
10381038 }
10391039
1040+/**
1041+ * i40e_reuse_rx_page - page flip buffer and store it back on the ring
1042+ * @rx_ring: rx descriptor ring to store buffers on
1043+ * @old_buff: donor buffer to have page reused
1044+ *
1045+ * Synchronizes page for reuse by the adapter
1046+ **/
1047+static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
1048+ struct i40e_rx_buffer *old_buff)
1049+{
1050+ struct i40e_rx_buffer *new_buff;
1051+ u16 nta = rx_ring->next_to_alloc;
1052+
1053+ new_buff = &rx_ring->rx_bi[nta];
1054+
1055+ /* update, and store next to alloc */
1056+ nta++;
1057+ rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
1058+
1059+ /* transfer page from old buffer to new buffer */
1060+ new_buff->dma = old_buff->dma;
1061+ new_buff->page = old_buff->page;
1062+ new_buff->page_offset = old_buff->page_offset;
1063+ new_buff->pagecnt_bias = old_buff->pagecnt_bias;
1064+}
1065+
10401066 /**
10411067 * i40e_rx_is_programming_status - check for programming status descriptor
10421068 * @qw: qword representing status_error_len in CPU ordering
@@ -1071,15 +1097,24 @@ static void i40e_clean_programming_status(struct i40e_ring *rx_ring, · 28 unmodified lines
10711097 union i40e_rx_desc *rx_desc,
10721098 u64 qw)
10731099 {
1074− u32 ntc = rx_ring->next_to_clean + 1;
1100+ struct i40e_rx_buffer *rx_buffer;
1101+ u32 ntc = rx_ring->next_to_clean;
10751102 u8 id;
10761103
10771104 /* fetch, update, and store next to clean */
1105+ rx_buffer = &rx_ring->rx_bi[ntc++];
10781106 ntc = (ntc < rx_ring->count) ? ntc : 0;
10791107 rx_ring->next_to_clean = ntc;
10801108
10811109 prefetch(I40E_RX_DESC(rx_ring, ntc));
10821110
1111+ /* place unused page back on the ring */
1112+ i40e_reuse_rx_page(rx_ring, rx_buffer);
1113+ rx_ring->rx_stats.page_reuse_count++;
1114+
1115+ /* clear contents of buffer_info */
1116+ rx_buffer->page = NULL;
1117+
10831118 id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >>
10841119 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
10851120
@@ -1638,32 +1673,6 @@ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb, · 552 unmodified lines
16381673 return false;
16391674 }
16401675
1641−/**
1642− * i40e_reuse_rx_page - page flip buffer and store it back on the ring
1643− * @rx_ring: rx descriptor ring to store buffers on
1644− * @old_buff: donor buffer to have page reused
1645− *
1646− * Synchronizes page for reuse by the adapter
1647− **/
1648−static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,
1649− struct i40e_rx_buffer *old_buff)
1650−{
1651− struct i40e_rx_buffer *new_buff;
1652− u16 nta = rx_ring->next_to_alloc;
1653−
1654− new_buff = &rx_ring->rx_bi[nta];
1655−
1656− /* update, and store next to alloc */
1657− nta++;
1658− rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
1659−
1660− /* transfer page from old buffer to new buffer */
1661− new_buff->dma = old_buff->dma;
1662− new_buff->page = old_buff->page;
1663− new_buff->page_offset = old_buff->page_offset;
1664− new_buff->pagecnt_bias = old_buff->pagecnt_bias;
1665−}
1666−
16671676 /**
16681677 * i40e_page_is_reusable - check if any reuse is possible
16691678 * @page: page struct to check
drivers/net/ethernet/mellanox/mlxsw/core.c+10−1
@@ -96,6 +96,7 @@ struct mlxsw_core { · 95 unmodified lines
9696 const struct mlxsw_bus *bus;
9797 void *bus_priv;
9898 const struct mlxsw_bus_info *bus_info;
99+ struct workqueue_struct *emad_wq;
99100 struct list_head rx_listener_list;
100101 struct list_head event_listener_list;
101102 struct {
@@ -465,7 +466,7 @@ static void mlxsw_emad_trans_timeout_schedule(struct mlxsw_reg_trans *trans) · 363 unmodified lines
465466 {
466467 unsigned long timeout = msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS);
467468
468− mlxsw_core_schedule_dw(&trans->timeout_dw, timeout);
469+ queue_delayed_work(trans->core->emad_wq, &trans->timeout_dw, timeout);
469470 }
470471
471472 static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,
@@ -587,12 +588,18 @@ static const struct mlxsw_listener mlxsw_emad_rx_listener = · 115 unmodified lines
587588
588589 static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
589590 {
591+ struct workqueue_struct *emad_wq;
590592 u64 tid;
591593 int err;
592594
593595 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
594596 return 0;
595597
598+ emad_wq = alloc_workqueue("mlxsw_core_emad", WQ_MEM_RECLAIM, 0);
599+ if (!emad_wq)
600+ return -ENOMEM;
601+ mlxsw_core->emad_wq = emad_wq;
602+
596603 /* Set the upper 32 bits of the transaction ID field to a random
597604 * number. This allows us to discard EMADs addressed to other
598605 * devices.
@@ -619,6 +626,7 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core) · 20 unmodified lines
619626 err_emad_trap_set:
620627 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
621628 mlxsw_core);
629+ destroy_workqueue(mlxsw_core->emad_wq);
622630 return err;
623631 }
624632
@@ -631,6 +639,7 @@ static void mlxsw_emad_fini(struct mlxsw_core *mlxsw_core) · 6 unmodified lines
631639 mlxsw_core->emad.use_emad = false;
632640 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
633641 mlxsw_core);
642+ destroy_workqueue(mlxsw_core->emad_wq);
634643 }
635644
636645 static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,
drivers/net/ethernet/mellanox/mlxsw/reg.h+31−0
@@ -6401,6 +6401,36 @@ static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index, · 6400 unmodified lines
64016401 mlxsw_reg_mgpc_opcode_set(payload, opcode);
64026402 }
64036403
6404+/* TIGCR - Tunneling IPinIP General Configuration Register
6405+ * -------------------------------------------------------
6406+ * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
6407+ */
6408+#define MLXSW_REG_TIGCR_ID 0xA801
6409+#define MLXSW_REG_TIGCR_LEN 0x10
6410+
6411+MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
6412+
6413+/* reg_tigcr_ipip_ttlc
6414+ * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
6415+ * header.
6416+ * Access: RW
6417+ */
6418+MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
6419+
6420+/* reg_tigcr_ipip_ttl_uc
6421+ * The TTL for IPinIP Tunnel encapsulation of unicast packets if
6422+ * reg_tigcr_ipip_ttlc is unset.
6423+ * Access: RW
6424+ */
6425+MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
6426+
6427+static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
6428+{
6429+ MLXSW_REG_ZERO(tigcr, payload);
6430+ mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
6431+ mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
6432+}
6433+
64046434 /* SBPR - Shared Buffer Pools Register
64056435 * -----------------------------------
64066436 * The SBPR configures and retrieves the shared buffer pools and configuration.
@@ -6881,6 +6911,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { · 474 unmodified lines
68816911 MLXSW_REG(mcc),
68826912 MLXSW_REG(mcda),
68836913 MLXSW_REG(mgpc),
6914+ MLXSW_REG(tigcr),
68846915 MLXSW_REG(sbpr),
68856916 MLXSW_REG(sbcm),
68866917 MLXSW_REG(sbpm),
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+10−1
@@ -5896,11 +5896,20 @@ static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp) · 5895 unmodified lines
58965896 kfree(mlxsw_sp->router->rifs);
58975897 }
58985898
5899+static int
5900+mlxsw_sp_ipip_config_tigcr(struct mlxsw_sp *mlxsw_sp)
5901+{
5902+ char tigcr_pl[MLXSW_REG_TIGCR_LEN];
5903+
5904+ mlxsw_reg_tigcr_pack(tigcr_pl, true, 0);
5905+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(tigcr), tigcr_pl);
5906+}
5907+
58995908 static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)
59005909 {
59015910 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;
59025911 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list);
5903− return 0;
5912+ return mlxsw_sp_ipip_config_tigcr(mlxsw_sp);
59045913 }
59055914
59065915 static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp)
drivers/net/ethernet/netronome/nfp/nfp_net_common.c+14−6
@@ -1180,10 +1180,14 @@ static void *nfp_net_rx_alloc_one(struct nfp_net_dp *dp, dma_addr_t *dma_addr) · 1179 unmodified lines
11801180 {
11811181 void *frag;
11821182
1183− if (!dp->xdp_prog)
1183+ if (!dp->xdp_prog) {
11841184 frag = netdev_alloc_frag(dp->fl_bufsz);
1185− else
1186− frag = page_address(alloc_page(GFP_KERNEL | __GFP_COLD));
1185+ } else {
1186+ struct page *page;
1187+
1188+ page = alloc_page(GFP_KERNEL | __GFP_COLD);
1189+ frag = page ? page_address(page) : NULL;
1190+ }
11871191 if (!frag) {
11881192 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
11891193 return NULL;
@@ -1203,10 +1207,14 @@ static void *nfp_net_napi_alloc_one(struct nfp_net_dp *dp, dma_addr_t *dma_addr) · 13 unmodified lines
12031207 {
12041208 void *frag;
12051209
1206− if (!dp->xdp_prog)
1210+ if (!dp->xdp_prog) {
12071211 frag = napi_alloc_frag(dp->fl_bufsz);
1208− else
1209− frag = page_address(alloc_page(GFP_ATOMIC | __GFP_COLD));
1212+ } else {
1213+ struct page *page;
1214+
1215+ page = alloc_page(GFP_ATOMIC | __GFP_COLD);
1216+ frag = page ? page_address(page) : NULL;
1217+ }
12101218 if (!frag) {
12111219 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
12121220 return NULL;
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c+5−3
@@ -464,7 +464,7 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) · 463 unmodified lines
464464
465465 do {
466466 start = u64_stats_fetch_begin(&nn->r_vecs[i].rx_sync);
467− *data++ = nn->r_vecs[i].rx_pkts;
467+ data[0] = nn->r_vecs[i].rx_pkts;
468468 tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;
469469 tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;
470470 tmp[2] = nn->r_vecs[i].hw_csum_rx_error;
@@ -472,14 +472,16 @@ static u64 *nfp_vnic_get_sw_stats(struct net_device *netdev, u64 *data) · 1 unmodified line
472472
473473 do {
474474 start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);
475− *data++ = nn->r_vecs[i].tx_pkts;
476− *data++ = nn->r_vecs[i].tx_busy;
475+ data[1] = nn->r_vecs[i].tx_pkts;
476+ data[2] = nn->r_vecs[i].tx_busy;
477477 tmp[3] = nn->r_vecs[i].hw_csum_tx;
478478 tmp[4] = nn->r_vecs[i].hw_csum_tx_inner;
479479 tmp[5] = nn->r_vecs[i].tx_gather;
480480 tmp[6] = nn->r_vecs[i].tx_lso;
481481 } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));
482482
483+ data += 3;
484+
483485 for (j = 0; j < NN_ET_RVEC_GATHER_STATS; j++)
484486 gathered_stats[j] += tmp[j];
485487 }
drivers/net/ethernet/realtek/r8169.c+0−2
@@ -8491,8 +8491,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 8490 unmodified lines
84918491 rtl8168_driver_start(tp);
84928492 }
84938493
8494− device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
8495−
84968494 if (pci_dev_run_wake(pdev))
84978495 pm_runtime_put_noidle(&pdev->dev);
84988496
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c+1−1
@@ -275,7 +275,7 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats) · 274 unmodified lines
275275 goto exit;
276276 i++;
277277
278− } while ((ret == 1) || (i < 10));
278+ } while ((ret == 1) && (i < 10));
279279
280280 if (i == 10)
281281 ret = -EBUSY;
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c+1−1
@@ -34,7 +34,7 @@ int dwmac_dma_reset(void __iomem *ioaddr) · 33 unmodified lines
3434
3535 err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
3636 !(value & DMA_BUS_MODE_SFT_RESET),
37− 100000, 10000);
37+ 10000, 100000);
3838 if (err)
3939 return -EBUSY;
4040
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+9−8
@@ -473,19 +473,18 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, · 472 unmodified lines
473473 struct dma_desc *np, struct sk_buff *skb)
474474 {
475475 struct skb_shared_hwtstamps *shhwtstamp = NULL;
476+ struct dma_desc *desc = p;
476477 u64 ns;
477478
478479 if (!priv->hwts_rx_en)
479480 return;
481+ /* For GMAC4, the valid timestamp is from CTX next desc. */
482+ if (priv->plat->has_gmac4)
483+ desc = np;
480484
481485 /* Check if timestamp is available */
482− if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) {
483− /* For GMAC4, the valid timestamp is from CTX next desc. */
484− if (priv->plat->has_gmac4)
485− ns = priv->hw->desc->get_timestamp(np, priv->adv_ts);
486− else
487− ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
488−
486+ if (priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) {
487+ ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
489488 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
490489 shhwtstamp = skb_hwtstamps(skb);
491490 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
@@ -1800,12 +1799,13 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue) · 1308 unmodified lines
18001799 {
18011800 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];
18021801 unsigned int bytes_compl = 0, pkts_compl = 0;
1803− unsigned int entry = tx_q->dirty_tx;
1802+ unsigned int entry;
18041803
18051804 netif_tx_lock(priv->dev);
18061805
18071806 priv->xstats.tx_clean++;
18081807
1808+ entry = tx_q->dirty_tx;
18091809 while (entry != tx_q->cur_tx) {
18101810 struct sk_buff *skb = tx_q->tx_skbuff[entry];
18111811 struct dma_desc *p;
@@ -3333,6 +3333,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) · 1521 unmodified lines
33333333 * them in stmmac_rx_refill() function so that
33343334 * device can reuse it.
33353335 */
3336+ dev_kfree_skb_any(rx_q->rx_skbuff[entry]);
33363337 rx_q->rx_skbuff[entry] = NULL;
33373338 dma_unmap_single(priv->device,
33383339 rx_q->rx_skbuff_dma[entry],
drivers/net/geneve.c+0−6
@@ -113,13 +113,7 @@ static void tunnel_id_to_vni(__be64 tun_id, __u8 *vni) · 112 unmodified lines
113113
114114 static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni)
115115 {
116−#ifdef __BIG_ENDIAN
117− return (vni[0] == tun_id[2]) &&
118− (vni[1] == tun_id[1]) &&
119− (vni[2] == tun_id[0]);
120−#else
121116 return !memcmp(vni, &tun_id[5], 3);
122−#endif
123117 }
124118
125119 static sa_family_t geneve_get_sk_family(struct geneve_sock *gs)
drivers/net/macsec.c+2−0
@@ -742,6 +742,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb, · 741 unmodified lines
742742 sg_init_table(sg, ret);
743743 ret = skb_to_sgvec(skb, sg, 0, skb->len);
744744 if (unlikely(ret < 0)) {
745+ aead_request_free(req);
745746 macsec_txsa_put(tx_sa);
746747 kfree_skb(skb);
747748 return ERR_PTR(ret);
@@ -954,6 +955,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb, · 206 unmodified lines
954955 sg_init_table(sg, ret);
955956 ret = skb_to_sgvec(skb, sg, 0, skb->len);
956957 if (unlikely(ret < 0)) {
958+ aead_request_free(req);
957959 kfree_skb(skb);
958960 return ERR_PTR(ret);
959961 }
drivers/net/tun.c+3−0
@@ -2027,6 +2027,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) · 2026 unmodified lines
20272027
20282028 if (!dev)
20292029 return -ENOMEM;
2030+ err = dev_get_valid_name(net, dev, name);
2031+ if (err)
2032+ goto err_free_dev;
20302033
20312034 dev_net_set(dev, net);
20322035 dev->rtnl_link_ops = &tun_link_ops;
drivers/net/wimax/i2400m/fw.c+1−1
@@ -652,7 +652,7 @@ static int i2400m_download_chunk(struct i2400m *i2400m, const void *chunk, · 651 unmodified lines
652652 struct device *dev = i2400m_dev(i2400m);
653653 struct {
654654 struct i2400m_bootrom_header cmd;
655− u8 cmd_payload[chunk_len];
655+ u8 cmd_payload[];
656656 } __packed *buf;
657657 struct i2400m_bootrom_header ack;
658658
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c+2−1
@@ -429,7 +429,8 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr, · 428 unmodified lines
429429 if (code != BRCMF_E_IF && !fweh->evt_handler[code])
430430 return;
431431
432− if (datalen > BRCMF_DCMD_MAXLEN)
432+ if (datalen > BRCMF_DCMD_MAXLEN ||
433+ datalen + sizeof(*event_packet) > packet_len)
433434 return;
434435
435436 if (in_interrupt())
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c+97−100
@@ -14764,8 +14764,8 @@ static void wlc_phy_ipa_restore_tx_digi_filts_nphy(struct brcms_phy *pi) · 14763 unmodified lines
1476414764 }
1476514765
1476614766 static void
14767−wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys,
14768− u8 len)
14767+wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events,
14768+ const u8 *dlys, u8 len)
1476914769 {
1477014770 u32 t1_offset, t2_offset;
1477114771 u8 ctr;
@@ -15240,16 +15240,16 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) · 468 unmodified lines
1524015240 static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
1524115241 {
1524215242 u16 currband;
15243− s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
15244− s8 *lna1_gain_db = NULL;
15245− s8 *lna1_gain_db_2 = NULL;
15246− s8 *lna2_gain_db = NULL;
15247− s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };
15248− s8 *tia_gain_db;
15249− s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
15250− s8 *tia_gainbits;
15251− u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
15252− u16 *rfseq_init_gain;
15243+ static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
15244+ const s8 *lna1_gain_db = NULL;
15245+ const s8 *lna1_gain_db_2 = NULL;
15246+ const s8 *lna2_gain_db = NULL;
15247+ static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };
15248+ const s8 *tia_gain_db;
15249+ static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
15250+ const s8 *tia_gainbits;
15251+ static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
15252+ const u16 *rfseq_init_gain;
1525315253 u16 init_gaincode;
1525415254 u16 clip1hi_gaincode;
1525515255 u16 clip1md_gaincode = 0;
@@ -15310,10 +15310,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) · 54 unmodified lines
1531015310
1531115311 if ((freq <= 5080) || (freq == 5825)) {
1531215312
15313− s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };
15314− s8 lna1A_gain_db_2_rev7[] = {
15315− 11, 17, 22, 25};
15316− s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15313+ static const s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };
15314+ static const s8 lna1A_gain_db_2_rev7[] = { 11, 17, 22, 25};
15315+ static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
1531715316
1531815317 crsminu_th = 0x3e;
1531915318 lna1_gain_db = lna1A_gain_db_rev7;
@@ -15321,10 +15320,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) · 1 unmodified line
1532115320 lna2_gain_db = lna2A_gain_db_rev7;
1532215321 } else if ((freq >= 5500) && (freq <= 5700)) {
1532315322
15324− s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };
15325− s8 lna1A_gain_db_2_rev7[] = {
15326− 12, 18, 22, 26};
15327− s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
15323+ static const s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };
15324+ static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15325+ static const s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
1532815326
1532915327 crsminu_th = 0x45;
1533015328 clip1md_gaincode_B = 0x14;
@@ -15335,10 +15333,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) · 4 unmodified lines
1533515333 lna2_gain_db = lna2A_gain_db_rev7;
1533615334 } else {
1533715335
15338− s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };
15339− s8 lna1A_gain_db_2_rev7[] = {
15340− 12, 18, 22, 26};
15341− s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15336+ static const s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };
15337+ static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15338+ static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
1534215339
1534315340 crsminu_th = 0x41;
1534415341 lna1_gain_db = lna1A_gain_db_rev7;
@@ -15450,65 +15447,65 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) · 105 unmodified lines
1545015447 NPHY_RFSEQ_CMD_CLR_HIQ_DIS,
1545115448 NPHY_RFSEQ_CMD_SET_HPF_BW
1545215449 };
15453− u8 rfseq_updategainu_dlys[] = { 10, 30, 1 };
15454− s8 lna1G_gain_db[] = { 7, 11, 16, 23 };
15455− s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 };
15456− s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 };
15457− s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 };
15458− s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 };
15459− s8 lna1A_gain_db[] = { 7, 11, 17, 23 };
15460− s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 };
15461− s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 };
15462− s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 };
15463− s8 *lna1_gain_db = NULL;
15464− s8 lna2G_gain_db[] = { -5, 6, 10, 14 };
15465− s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 };
15466− s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 };
15467− s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 };
15468− s8 lna2A_gain_db[] = { -6, 2, 6, 10 };
15469− s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 };
15470− s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 };
15471− s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 };
15472− s8 *lna2_gain_db = NULL;
15473− s8 tiaG_gain_db[] = {
15450+ static const u8 rfseq_updategainu_dlys[] = { 10, 30, 1 };
15451+ static const s8 lna1G_gain_db[] = { 7, 11, 16, 23 };
15452+ static const s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 };
15453+ static const s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 };
15454+ static const s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 };
15455+ static const s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 };
15456+ static const s8 lna1A_gain_db[] = { 7, 11, 17, 23 };
15457+ static const s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 };
15458+ static const s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 };
15459+ static const s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 };
15460+ const s8 *lna1_gain_db = NULL;
15461+ static const s8 lna2G_gain_db[] = { -5, 6, 10, 14 };
15462+ static const s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 };
15463+ static const s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 };
15464+ static const s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 };
15465+ static const s8 lna2A_gain_db[] = { -6, 2, 6, 10 };
15466+ static const s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 };
15467+ static const s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 };
15468+ static const s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 };
15469+ const s8 *lna2_gain_db = NULL;
15470+ static const s8 tiaG_gain_db[] = {
1547415471 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };
15475− s8 tiaA_gain_db[] = {
15472+ static const s8 tiaA_gain_db[] = {
1547615473 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 };
15477− s8 tiaA_gain_db_rev4[] = {
15474+ static const s8 tiaA_gain_db_rev4[] = {
1547815475 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15479− s8 tiaA_gain_db_rev5[] = {
15476+ static const s8 tiaA_gain_db_rev5[] = {
1548015477 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15481− s8 tiaA_gain_db_rev6[] = {
15478+ static const s8 tiaA_gain_db_rev6[] = {
1548215479 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15483− s8 *tia_gain_db;
15484− s8 tiaG_gainbits[] = {
15480+ const s8 *tia_gain_db;
15481+ static const s8 tiaG_gainbits[] = {
1548515482 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
15486− s8 tiaA_gainbits[] = {
15483+ static const s8 tiaA_gainbits[] = {
1548715484 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 };
15488− s8 tiaA_gainbits_rev4[] = {
15485+ static const s8 tiaA_gainbits_rev4[] = {
1548915486 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15490− s8 tiaA_gainbits_rev5[] = {
15487+ static const s8 tiaA_gainbits_rev5[] = {
1549115488 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15492− s8 tiaA_gainbits_rev6[] = {
15489+ static const s8 tiaA_gainbits_rev6[] = {
1549315490 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15494− s8 *tia_gainbits;
15495− s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 };
15496− s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 };
15497− u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f };
15498− u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f };
15499− u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f };
15500− u16 rfseqG_init_gain_rev5_elna[] = {
15491+ const s8 *tia_gainbits;
15492+ static const s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 };
15493+ static const s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 };
15494+ static const u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f };
15495+ static const u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f };
15496+ static const u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f };
15497+ static const u16 rfseqG_init_gain_rev5_elna[] = {
1550115498 0x013f, 0x013f, 0x013f, 0x013f };
15502− u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f };
15503− u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f };
15504− u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f };
15505− u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f };
15506− u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f };
15507− u16 rfseqA_init_gain_rev4_elna[] = {
15499+ static const u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f };
15500+ static const u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f };
15501+ static const u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f };
15502+ static const u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f };
15503+ static const u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f };
15504+ static const u16 rfseqA_init_gain_rev4_elna[] = {
1550815505 0x314f, 0x314f, 0x314f, 0x314f };
15509− u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f };
15510− u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f };
15511− u16 *rfseq_init_gain;
15506+ static const u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f };
15507+ static const u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f };
15508+ const u16 *rfseq_init_gain;
1551215509 u16 initG_gaincode = 0x627e;
1551315510 u16 initG_gaincode_rev4 = 0x527e;
1551415511 u16 initG_gaincode_rev5 = 0x427e;
@@ -15538,10 +15535,10 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) · 23 unmodified lines
1553815535 u16 clip1mdA_gaincode_rev6 = 0x2084;
1553915536 u16 clip1md_gaincode = 0;
1554015537 u16 clip1loG_gaincode = 0x0074;
15541− u16 clip1loG_gaincode_rev5[] = {
15538+ static const u16 clip1loG_gaincode_rev5[] = {
1554215539 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c
1554315540 };
15544− u16 clip1loG_gaincode_rev6[] = {
15541+ static const u16 clip1loG_gaincode_rev6[] = {
1554515542 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e
1554615543 };
1554715544 u16 clip1loG_gaincode_rev6_224B0 = 0x1074;
@@ -16066,7 +16063,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) · 518 unmodified lines
1606616063
1606716064 static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
1606816065 {
16069− u8 rfseq_rx2tx_events[] = {
16066+ static const u8 rfseq_rx2tx_events[] = {
1607016067 NPHY_RFSEQ_CMD_NOP,
1607116068 NPHY_RFSEQ_CMD_RXG_FBW,
1607216069 NPHY_RFSEQ_CMD_TR_SWITCH,
@@ -16076,7 +16073,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 3 unmodified lines
1607616073 NPHY_RFSEQ_CMD_EXT_PA
1607716074 };
1607816075 u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 };
16079− u8 rfseq_tx2rx_events[] = {
16076+ static const u8 rfseq_tx2rx_events[] = {
1608016077 NPHY_RFSEQ_CMD_NOP,
1608116078 NPHY_RFSEQ_CMD_EXT_PA,
1608216079 NPHY_RFSEQ_CMD_TX_GAIN,
@@ -16085,8 +16082,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 2 unmodified lines
1608516082 NPHY_RFSEQ_CMD_RXG_FBW,
1608616083 NPHY_RFSEQ_CMD_CLR_HIQ_DIS
1608716084 };
16088− u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };
16089− u8 rfseq_tx2rx_events_rev3[] = {
16085+ static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };
16086+ static const u8 rfseq_tx2rx_events_rev3[] = {
1609016087 NPHY_REV3_RFSEQ_CMD_EXT_PA,
1609116088 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
1609216089 NPHY_REV3_RFSEQ_CMD_TX_GAIN,
@@ -16096,7 +16093,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 3 unmodified lines
1609616093 NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,
1609716094 NPHY_REV3_RFSEQ_CMD_END
1609816095 };
16099− u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 };
16096+ static const u8 rfseq_tx2rx_dlys_rev3[] = { 8, 4, 2, 2, 4, 4, 6, 1 };
1610016097 u8 rfseq_rx2tx_events_rev3[] = {
1610116098 NPHY_REV3_RFSEQ_CMD_NOP,
1610216099 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
@@ -16110,7 +16107,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 7 unmodified lines
1611016107 };
1611116108 u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 };
1611216109
16113− u8 rfseq_rx2tx_events_rev3_ipa[] = {
16110+ static const u8 rfseq_rx2tx_events_rev3_ipa[] = {
1611416111 NPHY_REV3_RFSEQ_CMD_NOP,
1611516112 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
1611616113 NPHY_REV3_RFSEQ_CMD_TR_SWITCH,
@@ -16121,15 +16118,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 4 unmodified lines
1612116118 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
1612216119 NPHY_REV3_RFSEQ_CMD_END
1612316120 };
16124− u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 };
16125− u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };
16121+ static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 };
16122+ static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };
1612616123
1612716124 s16 alpha0, alpha1, alpha2;
1612816125 s16 beta0, beta1, beta2;
1612916126 u32 leg_data_weights, ht_data_weights, nss1_data_weights,
1613016127 stbc_data_weights;
1613116128 u8 chan_freq_range = 0;
16132− u16 dac_control = 0x0002;
16129+ static const u16 dac_control = 0x0002;
1613316130 u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 };
1613416131 u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 };
1613516132 u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 };
@@ -16139,8 +16136,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 3 unmodified lines
1613916136 u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 };
1614016137 u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 };
1614116138 u16 *aux_adc_gain;
16142− u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };
16143− u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };
16139+ static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };
16140+ static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };
1614416141 s32 min_nvar_val = 0x18d;
1614516142 s32 min_nvar_offset_6mbps = 20;
1614616143 u8 pdetrange;
@@ -16151,9 +16148,9 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 4 unmodified lines
1615116148 u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77;
1615216149 u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77;
1615316150 u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77;
16154− u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 };
16155− u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16156− u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16151+ static const u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 };
16152+ static const u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16153+ static const u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
1615716154 u16 ipalvlshift_3p3_war_en = 0;
1615816155 u16 rccal_bcap_val, rccal_scap_val;
1615916156 u16 rccal_tx20_11b_bcap = 0;
@@ -24291,13 +24288,13 @@ static void wlc_phy_update_txcal_ladder_nphy(struct brcms_phy *pi, u16 core) · 8131 unmodified lines
2429124288 u16 bbmult;
2429224289 u16 tblentry;
2429324290
24294− struct nphy_txiqcal_ladder ladder_lo[] = {
24291+ static const struct nphy_txiqcal_ladder ladder_lo[] = {
2429524292 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
2429624293 {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5},
2429724294 {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7}
2429824295 };
2429924296
24300− struct nphy_txiqcal_ladder ladder_iq[] = {
24297+ static const struct nphy_txiqcal_ladder ladder_iq[] = {
2430124298 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
2430224299 {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1},
2430324300 {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7}
@@ -25773,67 +25770,67 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain, · 1469 unmodified lines
2577325770 u16 cal_gain[2];
2577425771 struct nphy_iqcal_params cal_params[2];
2577525772 u32 tbl_len;
25776− void *tbl_ptr;
25773+ const void *tbl_ptr;
2577725774 bool ladder_updated[2];
2577825775 u8 mphase_cal_lastphase = 0;
2577925776 int bcmerror = 0;
2578025777 bool phyhang_avoid_state = false;
2578125778
25782− u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
25779+ static const u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
2578325780 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901,
2578425781 0x1902,
2578525782 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607,
2578625783 0x6407
2578725784 };
2578825785
25789− u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = {
25786+ static const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = {
2579025787 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400,
2579125788 0x3200,
2579225789 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406,
2579325790 0x6407
2579425791 };
2579525792
25796− u16 tbl_tx_iqlo_cal_loft_ladder_40[] = {
25793+ static const u16 tbl_tx_iqlo_cal_loft_ladder_40[] = {
2579725794 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201,
2579825795 0x1202,
2579925796 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207,
2580025797 0x4707
2580125798 };
2580225799
25803− u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = {
25800+ static const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = {
2580425801 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900,
2580525802 0x2300,
2580625803 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706,
2580725804 0x4707
2580825805 };
2580925806
25810− u16 tbl_tx_iqlo_cal_startcoefs[] = {
25807+ static const u16 tbl_tx_iqlo_cal_startcoefs[] = {
2581125808 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
2581225809 0x0000
2581325810 };
2581425811
25815− u16 tbl_tx_iqlo_cal_cmds_fullcal[] = {
25812+ static const u16 tbl_tx_iqlo_cal_cmds_fullcal[] = {
2581625813 0x8123, 0x8264, 0x8086, 0x8245, 0x8056,
2581725814 0x9123, 0x9264, 0x9086, 0x9245, 0x9056
2581825815 };
2581925816
25820− u16 tbl_tx_iqlo_cal_cmds_recal[] = {
25817+ static const u16 tbl_tx_iqlo_cal_cmds_recal[] = {
2582125818 0x8101, 0x8253, 0x8053, 0x8234, 0x8034,
2582225819 0x9101, 0x9253, 0x9053, 0x9234, 0x9034
2582325820 };
2582425821
25825− u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = {
25822+ static const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = {
2582625823 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
2582725824 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
2582825825 0x0000
2582925826 };
2583025827
25831− u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = {
25828+ static const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = {
2583225829 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234,
2583325830 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234
2583425831 };
2583525832
25836− u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = {
25833+ static const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = {
2583725834 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223,
2583825835 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223
2583925836 };
drivers/net/wireless/intel/iwlwifi/cfg/7000.c+1−0
@@ -309,6 +309,7 @@ const struct iwl_cfg iwl3168_2ac_cfg = { · 308 unmodified lines
309309 .nvm_calib_ver = IWL3168_TX_POWER_VERSION,
310310 .pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
311311 .dccm_len = IWL7265_DCCM_LEN,
312+ .nvm_type = IWL_NVM_SDP,
312313 };
313314
314315 const struct iwl_cfg iwl7265_2ac_cfg = {
drivers/net/wireless/intel/iwlwifi/cfg/8000.c+1−1
@@ -164,7 +164,7 @@ static const struct iwl_tt_params iwl8000_tt_params = { · 163 unmodified lines
164164 .default_nvm_file_C_step = DEFAULT_NVM_FILE_FAMILY_8000C, \
165165 .thermal_params = &iwl8000_tt_params, \
166166 .apmg_not_supported = true, \
167− .ext_nvm = true, \
167+ .nvm_type = IWL_NVM_EXT, \
168168 .dbgc_supported = true
169169
170170 #define IWL_DEVICE_8000 \
drivers/net/wireless/intel/iwlwifi/cfg/9000.c+1−1
@@ -148,7 +148,7 @@ static const struct iwl_tt_params iwl9000_tt_params = { · 147 unmodified lines
148148 .vht_mu_mimo_supported = true, \
149149 .mac_addr_from_csr = true, \
150150 .rf_id = true, \
151− .ext_nvm = true, \
151+ .nvm_type = IWL_NVM_EXT, \
152152 .dbgc_supported = true
153153
154154 const struct iwl_cfg iwl9160_2ac_cfg = {
drivers/net/wireless/intel/iwlwifi/cfg/a000.c+1−1
@@ -133,7 +133,7 @@ static const struct iwl_ht_params iwl_a000_ht_params = { · 132 unmodified lines
133133 .use_tfh = true, \
134134 .rf_id = true, \
135135 .gen2 = true, \
136− .ext_nvm = true, \
136+ .nvm_type = IWL_NVM_EXT, \
137137 .dbgc_supported = true
138138
139139 const struct iwl_cfg iwla000_2ac_cfg_hr = {
drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h+2−0
@@ -108,6 +108,7 @@ enum iwl_nvm_access_target { · 107 unmodified lines
108108 * @NVM_SECTION_TYPE_REGULATORY: regulatory section
109109 * @NVM_SECTION_TYPE_CALIBRATION: calibration section
110110 * @NVM_SECTION_TYPE_PRODUCTION: production section
111+ * @NVM_SECTION_TYPE_REGULATORY_SDP: regulatory section used by 3168 series
111112 * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
112113 * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
113114 * @NVM_MAX_NUM_SECTIONS: number of sections
@@ -117,6 +118,7 @@ enum iwl_nvm_section_type { · 3 unmodified lines
117118 NVM_SECTION_TYPE_REGULATORY = 3,
118119 NVM_SECTION_TYPE_CALIBRATION = 4,
119120 NVM_SECTION_TYPE_PRODUCTION = 5,
121+ NVM_SECTION_TYPE_REGULATORY_SDP = 8,
120122 NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
121123 NVM_SECTION_TYPE_PHY_SKU = 12,
122124 NVM_MAX_NUM_SECTIONS = 13,
drivers/net/wireless/intel/iwlwifi/fw/dbg.c+2−5
@@ -1086,7 +1086,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work) · 1085 unmodified lines
10861086
10871087 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
10881088 /* stop recording */
1089− iwl_set_bits_prph(fwrt->trans, MON_BUFF_SAMPLE_CTL, 0x100);
1089+ iwl_fw_dbg_stop_recording(fwrt);
10901090
10911091 iwl_fw_error_dump(fwrt);
10921092
@@ -1104,10 +1104,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work) · 11 unmodified lines
11041104 u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE);
11051105 u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL);
11061106
1107− /* stop recording */
1108− iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, 0);
1109− udelay(100);
1110− iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, 0);
1107+ iwl_fw_dbg_stop_recording(fwrt);
11111108 /* wait before we collect the data till the DBGC stop */
11121109 udelay(500);
11131110
drivers/net/wireless/intel/iwlwifi/fw/dbg.h+15−0
@@ -68,6 +68,8 @@ · 67 unmodified lines
6868 #include <linux/workqueue.h>
6969 #include <net/cfg80211.h>
7070 #include "runtime.h"
71+#include "iwl-prph.h"
72+#include "iwl-io.h"
7173 #include "file.h"
7274 #include "error-dump.h"
7375
@@ -194,8 +196,21 @@ _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt, · 120 unmodified lines
194196 iwl_fw_dbg_get_trigger((fwrt)->fw,\
195197 (trig)))
196198
199+static inline void iwl_fw_dbg_stop_recording(struct iwl_fw_runtime *fwrt)
200+{
201+ if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
202+ iwl_set_bits_prph(fwrt->trans, MON_BUFF_SAMPLE_CTL, 0x100);
203+ } else {
204+ iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, 0);
205+ udelay(100);
206+ iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, 0);
207+ }
208+}
209+
197210 static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)
198211 {
212+ iwl_fw_dbg_stop_recording(fwrt);
213+
199214 fwrt->dump.conf = FW_DBG_INVALID;
200215 }
201216
drivers/net/wireless/intel/iwlwifi/iwl-config.h+14−2
@@ -108,6 +108,18 @@ enum iwl_led_mode { · 107 unmodified lines
108108 IWL_LED_DISABLE,
109109 };
110110
111+/**
112+ * enum iwl_nvm_type - nvm formats
113+ * @IWL_NVM: the regular format
114+ * @IWL_NVM_EXT: extended NVM format
115+ * @IWL_NVM_SDP: NVM format used by 3168 series
116+ */
117+enum iwl_nvm_type {
118+ IWL_NVM,
119+ IWL_NVM_EXT,
120+ IWL_NVM_SDP,
121+};
122+
111123 /*
112124 * This is the threshold value of plcp error rate per 100mSecs. It is
113125 * used to set and check for the validity of plcp_delta.
@@ -320,7 +332,7 @@ struct iwl_pwr_tx_backoff { · 206 unmodified lines
320332 * @integrated: discrete or integrated
321333 * @gen2: a000 and on transport operation
322334 * @cdb: CDB support
323− * @ext_nvm: extended NVM format
335+ * @nvm_type: see &enum iwl_nvm_type
324336 *
325337 * We enable the driver to be backward compatible wrt. hardware features.
326338 * API differences in uCode shouldn't be handled here but through TLVs
@@ -342,6 +354,7 @@ struct iwl_cfg { · 15 unmodified lines
342354 const struct iwl_tt_params *thermal_params;
343355 enum iwl_device_family device_family;
344356 enum iwl_led_mode led_mode;
357+ enum iwl_nvm_type nvm_type;
345358 u32 max_data_size;
346359 u32 max_inst_size;
347360 netdev_features_t features;
@@ -369,7 +382,6 @@ struct iwl_cfg { · 21 unmodified lines
369382 use_tfh:1,
370383 gen2:1,
371384 cdb:1,
372− ext_nvm:1,
373385 dbgc_supported:1;
374386 u8 valid_tx_ant;
375387 u8 valid_rx_ant;
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c+62−75
@@ -77,7 +77,7 @@ · 76 unmodified lines
7777 #include "iwl-csr.h"
7878
7979 /* NVM offsets (in words) definitions */
80−enum wkp_nvm_offsets {
80+enum nvm_offsets {
8181 /* NVM HW-Section offset (in words) definitions */
8282 SUBSYSTEM_ID = 0x0A,
8383 HW_ADDR = 0x15,
@@ -92,7 +92,10 @@ enum wkp_nvm_offsets { · 8 unmodified lines
9292
9393 /* NVM calibration section offset (in words) definitions */
9494 NVM_CALIB_SECTION = 0x2B8,
95− XTAL_CALIB = 0x316 - NVM_CALIB_SECTION
95+ XTAL_CALIB = 0x316 - NVM_CALIB_SECTION,
96+
97+ /* NVM REGULATORY -Section offset (in words) definitions */
98+ NVM_CHANNELS_SDP = 0,
9699 };
97100
98101 enum ext_nvm_offsets {
@@ -206,8 +209,36 @@ enum iwl_nvm_channel_flags { · 107 unmodified lines
206209 NVM_CHANNEL_DC_HIGH = BIT(12),
207210 };
208211
212+static inline void iwl_nvm_print_channel_flags(struct device *dev, u32 level,
213+ int chan, u16 flags)
214+{
209215 #define CHECK_AND_PRINT_I(x) \
210− ((ch_flags & NVM_CHANNEL_##x) ? # x " " : "")
216+ ((flags & NVM_CHANNEL_##x) ? " " #x : "")
217+
218+ if (!(flags & NVM_CHANNEL_VALID)) {
219+ IWL_DEBUG_DEV(dev, level, "Ch. %d: 0x%x: No traffic\n",
220+ chan, flags);
221+ return;
222+ }
223+
224+ /* Note: already can print up to 101 characters, 110 is the limit! */
225+ IWL_DEBUG_DEV(dev, level,
226+ "Ch. %d: 0x%x:%s%s%s%s%s%s%s%s%s%s%s%s\n",
227+ chan, flags,
228+ CHECK_AND_PRINT_I(VALID),
229+ CHECK_AND_PRINT_I(IBSS),
230+ CHECK_AND_PRINT_I(ACTIVE),
231+ CHECK_AND_PRINT_I(RADAR),
232+ CHECK_AND_PRINT_I(INDOOR_ONLY),
233+ CHECK_AND_PRINT_I(GO_CONCURRENT),
234+ CHECK_AND_PRINT_I(UNIFORM),
235+ CHECK_AND_PRINT_I(20MHZ),
236+ CHECK_AND_PRINT_I(40MHZ),
237+ CHECK_AND_PRINT_I(80MHZ),
238+ CHECK_AND_PRINT_I(160MHZ),
239+ CHECK_AND_PRINT_I(DC_HIGH));
240+#undef CHECK_AND_PRINT_I
241+}
211242
212243 static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,
213244 u16 nvm_flags, const struct iwl_cfg *cfg)
@@ -215,7 +246,7 @@ static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz, · 1 unmodified line
215246 u32 flags = IEEE80211_CHAN_NO_HT40;
216247 u32 last_5ghz_ht = LAST_5GHZ_HT;
217248
218− if (cfg->ext_nvm)
249+ if (cfg->nvm_type == IWL_NVM_EXT)
219250 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
220251
221252 if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) {
@@ -268,7 +299,7 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, · 46 unmodified lines
268299 int num_of_ch, num_2ghz_channels;
269300 const u8 *nvm_chan;
270301
271− if (!cfg->ext_nvm) {
302+ if (cfg->nvm_type != IWL_NVM_EXT) {
272303 num_of_ch = IWL_NUM_CHANNELS;
273304 nvm_chan = &iwl_nvm_channels[0];
274305 num_2ghz_channels = NUM_2GHZ_CHANNELS;
@@ -302,12 +333,8 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, · 27 unmodified lines
302333 * supported, hence we still want to add them to
303334 * the list of supported channels to cfg80211.
304335 */
305− IWL_DEBUG_EEPROM(dev,
306− "Ch. %d Flags %x [%sGHz] - No traffic\n",
307− nvm_chan[ch_idx],
308− ch_flags,
309− (ch_idx >= num_2ghz_channels) ?
310− "5.2" : "2.4");
336+ iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
337+ nvm_chan[ch_idx], ch_flags);
311338 continue;
312339 }
313340
@@ -337,27 +364,10 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, · 23 unmodified lines
337364 else
338365 channel->flags = 0;
339366
340− IWL_DEBUG_EEPROM(dev,
341− "Ch. %d [%sGHz] flags 0x%x %s%s%s%s%s%s%s%s%s%s%s%s(%ddBm): Ad-Hoc %ssupported\n",
342− channel->hw_value,
343− is_5ghz ? "5.2" : "2.4",
344− ch_flags,
345− CHECK_AND_PRINT_I(VALID),
346− CHECK_AND_PRINT_I(IBSS),
347− CHECK_AND_PRINT_I(ACTIVE),
348− CHECK_AND_PRINT_I(RADAR),
349− CHECK_AND_PRINT_I(INDOOR_ONLY),
350− CHECK_AND_PRINT_I(GO_CONCURRENT),
351− CHECK_AND_PRINT_I(UNIFORM),
352− CHECK_AND_PRINT_I(20MHZ),
353− CHECK_AND_PRINT_I(40MHZ),
354− CHECK_AND_PRINT_I(80MHZ),
355− CHECK_AND_PRINT_I(160MHZ),
356− CHECK_AND_PRINT_I(DC_HIGH),
357− channel->max_power,
358− ((ch_flags & NVM_CHANNEL_IBSS) &&
359− !(ch_flags & NVM_CHANNEL_RADAR))
360− ? "" : "not ");
367+ iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
368+ channel->hw_value, ch_flags);
369+ IWL_DEBUG_EEPROM(dev, "Ch. %d: %ddBm\n",
370+ channel->hw_value, channel->max_power);
361371 }
362372
363373 return n_channels;
@@ -484,7 +494,7 @@ IWL_EXPORT_SYMBOL(iwl_init_sbands); · 120 unmodified lines
484494 static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
485495 const __le16 *phy_sku)
486496 {
487− if (!cfg->ext_nvm)
497+ if (cfg->nvm_type != IWL_NVM_EXT)
488498 return le16_to_cpup(nvm_sw + SKU);
489499
490500 return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000));
@@ -492,7 +502,7 @@ static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw, · 1 unmodified line
492502
493503 static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw)
494504 {
495− if (!cfg->ext_nvm)
505+ if (cfg->nvm_type != IWL_NVM_EXT)
496506 return le16_to_cpup(nvm_sw + NVM_VERSION);
497507 else
498508 return le32_to_cpup((__le32 *)(nvm_sw +
@@ -502,7 +512,7 @@ static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw) · 3 unmodified lines
502512 static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
503513 const __le16 *phy_sku)
504514 {
505− if (!cfg->ext_nvm)
515+ if (cfg->nvm_type != IWL_NVM_EXT)
506516 return le16_to_cpup(nvm_sw + RADIO_CFG);
507517
508518 return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_EXT_NVM));
@@ -513,7 +523,7 @@ static int iwl_get_n_hw_addrs(const struct iwl_cfg *cfg, const __le16 *nvm_sw) · 4 unmodified lines
513523 {
514524 int n_hw_addr;
515525
516− if (!cfg->ext_nvm)
526+ if (cfg->nvm_type != IWL_NVM_EXT)
517527 return le16_to_cpup(nvm_sw + N_HW_ADDRS);
518528
519529 n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000));
@@ -525,7 +535,7 @@ static void iwl_set_radio_cfg(const struct iwl_cfg *cfg, · 5 unmodified lines
525535 struct iwl_nvm_data *data,
526536 u32 radio_cfg)
527537 {
528− if (!cfg->ext_nvm) {
538+ if (cfg->nvm_type != IWL_NVM_EXT) {
529539 data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg);
530540 data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg);
531541 data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg);
@@ -634,7 +644,7 @@ static int iwl_set_hw_address(struct iwl_trans *trans, · 102 unmodified lines
634644 {
635645 if (cfg->mac_addr_from_csr) {
636646 iwl_set_hw_address_from_csr(trans, data);
637− } else if (!cfg->ext_nvm) {
647+ } else if (cfg->nvm_type != IWL_NVM_EXT) {
638648 const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR);
639649
640650 /* The byte order is little endian 16 bit, meaning 214365 */
@@ -706,7 +716,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 65 unmodified lines
706716 u16 lar_config;
707717 const __le16 *ch_section;
708718
709− if (!cfg->ext_nvm)
719+ if (cfg->nvm_type != IWL_NVM_EXT)
710720 data = kzalloc(sizeof(*data) +
711721 sizeof(struct ieee80211_channel) *
712722 IWL_NUM_CHANNELS,
@@ -740,7 +750,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 27 unmodified lines
740750
741751 data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw);
742752
743− if (!cfg->ext_nvm) {
753+ if (cfg->nvm_type != IWL_NVM_EXT) {
744754 /* Checking for required sections */
745755 if (!nvm_calib) {
746756 IWL_ERR(trans,
@@ -748,11 +758,15 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 1 unmodified line
748758 kfree(data);
749759 return NULL;
750760 }
761+
762+ ch_section = cfg->nvm_type == IWL_NVM_SDP ?
763+ &regulatory[NVM_CHANNELS_SDP] :
764+ &nvm_sw[NVM_CHANNELS];
765+
751766 /* in family 8000 Xtal calibration values moved to OTP */
752767 data->xtal_calib[0] = *(nvm_calib + XTAL_CALIB);
753768 data->xtal_calib[1] = *(nvm_calib + XTAL_CALIB + 1);
754769 lar_enabled = true;
755− ch_section = &nvm_sw[NVM_CHANNELS];
756770 } else {
757771 u16 lar_offset = data->nvm_version < 0xE39 ?
758772 NVM_LAR_OFFSET_OLD :
@@ -786,7 +800,7 @@ static u32 iwl_nvm_get_regdom_bw_flags(const u8 *nvm_chan, · 27 unmodified lines
786800 u32 flags = NL80211_RRF_NO_HT40;
787801 u32 last_5ghz_ht = LAST_5GHZ_HT;
788802
789− if (cfg->ext_nvm)
803+ if (cfg->nvm_type == IWL_NVM_EXT)
790804 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
791805
792806 if (ch_idx < NUM_2GHZ_CHANNELS &&
@@ -834,7 +848,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 41 unmodified lines
834848 int ch_idx;
835849 u16 ch_flags;
836850 u32 reg_rule_flags, prev_reg_rule_flags = 0;
837− const u8 *nvm_chan = cfg->ext_nvm ?
851+ const u8 *nvm_chan = cfg->nvm_type == IWL_NVM_EXT ?
838852 iwl_ext_nvm_channels : iwl_nvm_channels;
839853 struct ieee80211_regdomain *regd;
840854 int size_of_regd;
@@ -843,7 +857,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 2 unmodified lines
843857 int center_freq, prev_center_freq = 0;
844858 int valid_rules = 0;
845859 bool new_rule;
846− int max_num_ch = cfg->ext_nvm ?
860+ int max_num_ch = cfg->nvm_type == IWL_NVM_EXT ?
847861 IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS;
848862
849863 if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES))
@@ -873,12 +887,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 23 unmodified lines
873887 new_rule = false;
874888
875889 if (!(ch_flags & NVM_CHANNEL_VALID)) {
876− IWL_DEBUG_DEV(dev, IWL_DL_LAR,
877− "Ch. %d Flags %x [%sGHz] - No traffic\n",
878− nvm_chan[ch_idx],
879− ch_flags,
880− (ch_idx >= NUM_2GHZ_CHANNELS) ?
881− "5.2" : "2.4");
890+ iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
891+ nvm_chan[ch_idx], ch_flags);
882892 continue;
883893 }
884894
@@ -914,31 +924,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 29 unmodified lines
914924 prev_center_freq = center_freq;
915925 prev_reg_rule_flags = reg_rule_flags;
916926
917− IWL_DEBUG_DEV(dev, IWL_DL_LAR,
918− "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s%s%s%s(0x%02x)\n",
919− center_freq,
920− band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
921− CHECK_AND_PRINT_I(VALID),
922− CHECK_AND_PRINT_I(IBSS),
923− CHECK_AND_PRINT_I(ACTIVE),
924− CHECK_AND_PRINT_I(RADAR),
925− CHECK_AND_PRINT_I(INDOOR_ONLY),
926− CHECK_AND_PRINT_I(GO_CONCURRENT),
927− CHECK_AND_PRINT_I(UNIFORM),
928− CHECK_AND_PRINT_I(20MHZ),
929− CHECK_AND_PRINT_I(40MHZ),
930− CHECK_AND_PRINT_I(80MHZ),
931− CHECK_AND_PRINT_I(160MHZ),
932− CHECK_AND_PRINT_I(DC_HIGH),
933− ch_flags);
934− IWL_DEBUG_DEV(dev, IWL_DL_LAR,
935− "Ch. %d [%sGHz] reg_flags 0x%x: %s\n",
936− center_freq,
937− band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
938− reg_rule_flags,
939− ((ch_flags & NVM_CHANNEL_ACTIVE) &&
940− !(ch_flags & NVM_CHANNEL_RADAR))
941− ? "Ad-Hoc" : "");
927+ iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
928+ nvm_chan[ch_idx], ch_flags);
942929 }
943930
944931 regd->n_reg_rules = valid_rules;
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c+7−0
@@ -1077,6 +1077,7 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) · 1076 unmodified lines
10771077 mvm->vif_count = 0;
10781078 mvm->rx_ba_sessions = 0;
10791079 mvm->fwrt.dump.conf = FW_DBG_INVALID;
1080+ mvm->monitor_on = false;
10801081
10811082 /* keep statistics ticking */
10821083 iwl_mvm_accu_radio_stats(mvm);
@@ -1437,6 +1438,9 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, · 354 unmodified lines
14371438 mvm->p2p_device_vif = vif;
14381439 }
14391440
1441+ if (vif->type == NL80211_IFTYPE_MONITOR)
1442+ mvm->monitor_on = true;
1443+
14401444 iwl_mvm_vif_dbgfs_register(mvm, vif);
14411445 goto out_unlock;
14421446
@@ -1526,6 +1530,9 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, · 83 unmodified lines
15261530 iwl_mvm_power_update_mac(mvm);
15271531 iwl_mvm_mac_ctxt_remove(mvm, vif);
15281532
1533+ if (vif->type == NL80211_IFTYPE_MONITOR)
1534+ mvm->monitor_on = false;
1535+
15291536 out_release:
15301537 mutex_unlock(&mvm->mutex);
15311538 }
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h+4−1
@@ -1015,6 +1015,9 @@ struct iwl_mvm { · 1014 unmodified lines
10151015 bool drop_bcn_ap_mode;
10161016
10171017 struct delayed_work cs_tx_unblock_dwork;
1018+
1019+ /* does a monitor vif exist (only one can exist hence bool) */
1020+ bool monitor_on;
10181021 #ifdef CONFIG_ACPI
10191022 struct iwl_mvm_sar_profile sar_profiles[IWL_MVM_SAR_PROFILE_NUM];
10201023 struct iwl_mvm_geo_profile geo_profiles[IWL_NUM_GEO_PROFILES];
@@ -1159,7 +1162,7 @@ static inline bool iwl_mvm_is_lar_supported(struct iwl_mvm *mvm) · 138 unmodified lines
11591162 * Enable LAR only if it is supported by the FW (TLV) &&
11601163 * enabled in the NVM
11611164 */
1162− if (mvm->cfg->ext_nvm)
1165+ if (mvm->cfg->nvm_type == IWL_NVM_EXT)
11631166 return nvm_lar && tlv_lar;
11641167 else
11651168 return tlv_lar;
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c+15−6
@@ -295,18 +295,24 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm) · 294 unmodified lines
295295 const __be16 *hw;
296296 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;
297297 bool lar_enabled;
298+ int regulatory_type;
298299
299300 /* Checking for required sections */
300− if (!mvm->trans->cfg->ext_nvm) {
301+ if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
301302 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||
302303 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) {
303304 IWL_ERR(mvm, "Can't parse empty OTP/NVM sections\n");
304305 return NULL;
305306 }
306307 } else {
308+ if (mvm->trans->cfg->nvm_type == IWL_NVM_SDP)
309+ regulatory_type = NVM_SECTION_TYPE_REGULATORY_SDP;
310+ else
311+ regulatory_type = NVM_SECTION_TYPE_REGULATORY;
312+
307313 /* SW and REGULATORY sections are mandatory */
308314 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||
309− !mvm->nvm_sections[NVM_SECTION_TYPE_REGULATORY].data) {
315+ !mvm->nvm_sections[regulatory_type].data) {
310316 IWL_ERR(mvm,
311317 "Can't parse empty family 8000 OTP/NVM sections\n");
312318 return NULL;
@@ -330,11 +336,14 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm) · 17 unmodified lines
330336 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data;
331337 sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data;
332338 calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data;
333− regulatory = (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
334339 mac_override =
335340 (const __le16 *)sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data;
336341 phy_sku = (const __le16 *)sections[NVM_SECTION_TYPE_PHY_SKU].data;
337342
343+ regulatory = mvm->trans->cfg->nvm_type == IWL_NVM_SDP ?
344+ (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY_SDP].data :
345+ (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
346+
338347 lar_enabled = !iwlwifi_mod_params.lar_disable &&
339348 fw_has_capa(&mvm->fw->ucode_capa,
340349 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
@@ -394,7 +403,7 @@ int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm) · 53 unmodified lines
394403 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n");
395404
396405 /* Maximal size depends on NVM version */
397− if (!mvm->trans->cfg->ext_nvm)
406+ if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT)
398407 max_section_size = IWL_MAX_NVM_SECTION_SIZE;
399408 else
400409 max_section_size = IWL_MAX_EXT_NVM_SECTION_SIZE;
@@ -465,7 +474,7 @@ int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm) · 64 unmodified lines
465474 break;
466475 }
467476
468− if (!mvm->trans->cfg->ext_nvm) {
477+ if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
469478 section_size =
470479 2 * NVM_WORD1_LEN(le16_to_cpu(file_sec->word1));
471480 section_id = NVM_WORD2_ID(le16_to_cpu(file_sec->word2));
@@ -740,7 +749,7 @@ int iwl_mvm_init_mcc(struct iwl_mvm *mvm) · 268 unmodified lines
740749 struct ieee80211_regdomain *regd;
741750 char mcc[3];
742751
743− if (mvm->cfg->ext_nvm) {
752+ if (mvm->cfg->nvm_type == IWL_NVM_EXT) {
744753 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
745754 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
746755 nvm_lar = mvm->nvm_data->lar_enabled;
drivers/net/wireless/intel/iwlwifi/mvm/rx.c+3−1
@@ -244,7 +244,9 @@ static u32 iwl_mvm_set_mac80211_rx_flag(struct iwl_mvm *mvm, · 243 unmodified lines
244244 return 0;
245245
246246 default:
247− IWL_ERR(mvm, "Unhandled alg: 0x%x\n", rx_pkt_status);
247+ /* Expected in monitor (not having the keys) */
248+ if (!mvm->monitor_on)
249+ IWL_ERR(mvm, "Unhandled alg: 0x%x\n", rx_pkt_status);
248250 }
249251
250252 return 0;
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c+3−1
@@ -277,7 +277,9 @@ static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_hdr *hdr, · 276 unmodified lines
277277 stats->flag |= RX_FLAG_DECRYPTED;
278278 return 0;
279279 default:
280− IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status);
280+ /* Expected in monitor (not having the keys) */
281+ if (!mvm->monitor_on)
282+ IWL_ERR(mvm, "Unhandled alg: 0x%x\n", status);
281283 }
282284
283285 return 0;
drivers/net/wireless/intel/iwlwifi/mvm/tt.c+1−1
@@ -631,7 +631,7 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, · 630 unmodified lines
631631
632632 if (!iwl_mvm_firmware_running(mvm) ||
633633 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
634− ret = -EIO;
634+ ret = -ENODATA;
635635 goto out;
636636 }
637637
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c+1−1
@@ -1122,7 +1122,7 @@ static u8 _rtl8821ae_dbi_read(struct rtl_priv *rtlpriv, u16 addr) · 1121 unmodified lines
11221122 }
11231123 if (0 == tmp) {
11241124 read_addr = REG_DBI_RDATA + addr % 4;
1125− ret = rtl_read_byte(rtlpriv, read_addr);
1125+ ret = rtl_read_word(rtlpriv, read_addr);
11261126 }
11271127 return ret;
11281128 }
drivers/of/of_mdio.c+27−12
@@ -44,7 +44,7 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id) · 43 unmodified lines
4444 return -EINVAL;
4545 }
4646
47−static void of_mdiobus_register_phy(struct mii_bus *mdio,
47+static int of_mdiobus_register_phy(struct mii_bus *mdio,
4848 struct device_node *child, u32 addr)
4949 {
5050 struct phy_device *phy;
@@ -60,9 +60,13 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio, · 9 unmodified lines
6060 else
6161 phy = get_phy_device(mdio, addr, is_c45);
6262 if (IS_ERR(phy))
63− return;
63+ return PTR_ERR(phy);
6464
65− rc = irq_of_parse_and_map(child, 0);
65+ rc = of_irq_get(child, 0);
66+ if (rc == -EPROBE_DEFER) {
67+ phy_device_free(phy);
68+ return rc;
69+ }
6670 if (rc > 0) {
6771 phy->irq = rc;
6872 mdio->irq[addr] = rc;
@@ -84,22 +88,23 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio, · 15 unmodified lines
8488 if (rc) {
8589 phy_device_free(phy);
8690 of_node_put(child);
87− return;
91+ return rc;
8892 }
8993
9094 dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
9195 child->name, addr);
96+ return 0;
9297 }
9398
94−static void of_mdiobus_register_device(struct mii_bus *mdio,
95− struct device_node *child, u32 addr)
99+static int of_mdiobus_register_device(struct mii_bus *mdio,
100+ struct device_node *child, u32 addr)
96101 {
97102 struct mdio_device *mdiodev;
98103 int rc;
99104
100105 mdiodev = mdio_device_create(mdio, addr);
101106 if (IS_ERR(mdiodev))
102− return;
107+ return PTR_ERR(mdiodev);
103108
104109 /* Associate the OF node with the device structure so it
105110 * can be looked up later.
@@ -112,11 +117,12 @@ static void of_mdiobus_register_device(struct mii_bus *mdio, · 6 unmodified lines
112117 if (rc) {
113118 mdio_device_free(mdiodev);
114119 of_node_put(child);
115− return;
120+ return rc;
116121 }
117122
118123 dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n",
119124 child->name, addr);
125+ return 0;
120126 }
121127
122128 /* The following is a list of PHY compatible strings which appear in
@@ -219,9 +225,11 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 96 unmodified lines
219225 }
220226
221227 if (of_mdiobus_child_is_phy(child))
222− of_mdiobus_register_phy(mdio, child, addr);
228+ rc = of_mdiobus_register_phy(mdio, child, addr);
223229 else
224− of_mdiobus_register_device(mdio, child, addr);
230+ rc = of_mdiobus_register_device(mdio, child, addr);
231+ if (rc)
232+ goto unregister;
225233 }
226234
227235 if (!scanphys)
@@ -242,12 +250,19 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 14 unmodified lines
242250 dev_info(&mdio->dev, "scan phy %s at address %i\n",
243251 child->name, addr);
244252
245− if (of_mdiobus_child_is_phy(child))
246− of_mdiobus_register_phy(mdio, child, addr);
253+ if (of_mdiobus_child_is_phy(child)) {
254+ rc = of_mdiobus_register_phy(mdio, child, addr);
255+ if (rc)
256+ goto unregister;
257+ }
247258 }
248259 }
249260
250261 return 0;
262+
263+unregister:
264+ mdiobus_unregister(mdio);
265+ return rc;
251266 }
252267 EXPORT_SYMBOL(of_mdiobus_register);
253268
include/linux/filter.h+1−1
@@ -728,7 +728,7 @@ void xdp_do_flush_map(void); · 727 unmodified lines
728728 void bpf_warn_invalid_xdp_action(u32 act);
729729 void bpf_warn_invalid_xdp_redirect(u32 ifindex);
730730
731−struct sock *do_sk_redirect_map(void);
731+struct sock *do_sk_redirect_map(struct sk_buff *skb);
732732
733733 #ifdef CONFIG_BPF_JIT
734734 extern int bpf_jit_enable;
include/linux/netdevice.h+3−0
@@ -3694,6 +3694,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, · 3693 unmodified lines
36943694 unsigned char name_assign_type,
36953695 void (*setup)(struct net_device *),
36963696 unsigned int txqs, unsigned int rxqs);
3697+int dev_get_valid_name(struct net *net, struct net_device *dev,
3698+ const char *name);
3699+
36973700 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
36983701 alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)
36993702
include/net/inet_sock.h+1−1
@@ -96,7 +96,7 @@ struct inet_request_sock { · 95 unmodified lines
9696 kmemcheck_bitfield_end(flags);
9797 u32 ir_mark;
9898 union {
99− struct ip_options_rcu *opt;
99+ struct ip_options_rcu __rcu *ireq_opt;
100100 #if IS_ENABLED(CONFIG_IPV6)
101101 struct {
102102 struct ipv6_txoptions *ipv6_opt;
include/net/tcp.h+5−0
@@ -840,6 +840,11 @@ struct tcp_skb_cb { · 839 unmodified lines
840840 struct inet6_skb_parm h6;
841841 #endif
842842 } header; /* For incoming skbs */
843+ struct {
844+ __u32 key;
845+ __u32 flags;
846+ struct bpf_map *map;
847+ } bpf;
843848 };
844849 };
845850
kernel/bpf/arraymap.c+1−1
@@ -98,7 +98,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) · 97 unmodified lines
9898 array_size += (u64) attr->max_entries * elem_size * num_possible_cpus();
9999
100100 if (array_size >= U32_MAX - PAGE_SIZE ||
101− elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) {
101+ bpf_array_alloc_percpu(array)) {
102102 bpf_map_area_free(array);
103103 return ERR_PTR(-ENOMEM);
104104 }
kernel/bpf/devmap.c+7−3
@@ -69,7 +69,7 @@ static LIST_HEAD(dev_map_list); · 68 unmodified lines
6969
7070 static u64 dev_map_bitmap_size(const union bpf_attr *attr)
7171 {
72− return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long);
72+ return BITS_TO_LONGS((u64) attr->max_entries) * sizeof(unsigned long);
7373 }
7474
7575 static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
@@ -78,6 +78,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr) · 2 unmodified lines
7878 int err = -EINVAL;
7979 u64 cost;
8080
81+ if (!capable(CAP_NET_ADMIN))
82+ return ERR_PTR(-EPERM);
83+
8184 /* check sanity of attributes */
8285 if (attr->max_entries == 0 || attr->key_size != 4 ||
8386 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
@@ -111,8 +114,9 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr) · 27 unmodified lines
111114 err = -ENOMEM;
112115
113116 /* A per cpu bitfield with a bit per possible net device */
114− dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),
115− __alignof__(unsigned long));
117+ dtab->flush_needed = __alloc_percpu_gfp(dev_map_bitmap_size(attr),
118+ __alignof__(unsigned long),
119+ GFP_KERNEL | __GFP_NOWARN);
116120 if (!dtab->flush_needed)
117121 goto free_dtab;
118122
kernel/bpf/hashtab.c+0−4
@@ -317,10 +317,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) · 316 unmodified lines
317317 */
318318 goto free_htab;
319319
320− if (percpu && round_up(htab->map.value_size, 8) > PCPU_MIN_UNIT_SIZE)
321− /* make sure the size for pcpu_alloc() is reasonable */
322− goto free_htab;
323−
324320 htab->elem_size = sizeof(struct htab_elem) +
325321 round_up(htab->map.key_size, 8);
326322 if (percpu)
kernel/bpf/sockmap.c+18−10
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 #include <linux/workqueue.h>
4040 #include <linux/list.h>
4141 #include <net/strparser.h>
42+#include <net/tcp.h>
4243
4344 struct bpf_stab {
4445 struct bpf_map map;
@@ -101,9 +102,16 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb) · 56 unmodified lines
101102 return SK_DROP;
102103
103104 skb_orphan(skb);
105+ /* We need to ensure that BPF metadata for maps is also cleared
106+ * when we orphan the skb so that we don't have the possibility
107+ * to reference a stale map.
108+ */
109+ TCP_SKB_CB(skb)->bpf.map = NULL;
104110 skb->sk = psock->sock;
105111 bpf_compute_data_end(skb);
112+ preempt_disable();
106113 rc = (*prog->bpf_func)(skb, prog->insnsi);
114+ preempt_enable();
107115 skb->sk = NULL;
108116
109117 return rc;
@@ -114,17 +122,10 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) · 4 unmodified lines
114122 struct sock *sk;
115123 int rc;
116124
117− /* Because we use per cpu values to feed input from sock redirect
118− * in BPF program to do_sk_redirect_map() call we need to ensure we
119− * are not preempted. RCU read lock is not sufficient in this case
120− * with CONFIG_PREEMPT_RCU enabled so we must be explicit here.
121− */
122− preempt_disable();
123125 rc = smap_verdict_func(psock, skb);
124126 switch (rc) {
125127 case SK_REDIRECT:
126− sk = do_sk_redirect_map();
127− preempt_enable();
128+ sk = do_sk_redirect_map(skb);
128129 if (likely(sk)) {
129130 struct smap_psock *peer = smap_psock_sk(sk);
130131
@@ -141,8 +142,6 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) · 10 unmodified lines
141142 /* Fall through and free skb otherwise */
142143 case SK_DROP:
143144 default:
144− if (rc != SK_REDIRECT)
145− preempt_enable();
146145 kfree_skb(skb);
147146 }
148147 }
@@ -487,6 +486,9 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) · 338 unmodified lines
487486 int err = -EINVAL;
488487 u64 cost;
489488
489+ if (!capable(CAP_NET_ADMIN))
490+ return ERR_PTR(-EPERM);
491+
490492 /* check sanity of attributes */
491493 if (attr->max_entries == 0 || attr->key_size != 4 ||
492494 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)
@@ -840,6 +842,12 @@ static int sock_map_update_elem(struct bpf_map *map, · 347 unmodified lines
840842 return -EINVAL;
841843 }
842844
845+ if (skops.sk->sk_type != SOCK_STREAM ||
846+ skops.sk->sk_protocol != IPPROTO_TCP) {
847+ fput(socket->file);
848+ return -EOPNOTSUPP;
849+ }
850+
843851 err = sock_map_ctx_update_elem(&skops, map, key, flags);
844852 fput(socket->file);
845853 return err;
kernel/bpf/verifier.c+51−14
@@ -1116,7 +1116,12 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn · 1115 unmodified lines
11161116 /* ctx accesses must be at a fixed offset, so that we can
11171117 * determine what type of data were returned.
11181118 */
1119− if (!tnum_is_const(reg->var_off)) {
1119+ if (reg->off) {
1120+ verbose("dereference of modified ctx ptr R%d off=%d+%d, ctx+const is allowed, ctx+const+const is not\n",
1121+ regno, reg->off, off - reg->off);
1122+ return -EACCES;
1123+ }
1124+ if (!tnum_is_const(reg->var_off) || reg->var_off.value) {
11201125 char tn_buf[48];
11211126
11221127 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
@@ -1124,7 +1129,6 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn · 1 unmodified line
11241129 tn_buf, off, size);
11251130 return -EACCES;
11261131 }
1127− off += reg->var_off.value;
11281132 err = check_ctx_access(env, insn_idx, off, size, t, &reg_type);
11291133 if (!err && t == BPF_READ && value_regno >= 0) {
11301134 /* ctx access returns either a scalar, or a
@@ -2426,12 +2430,15 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) · 1295 unmodified lines
24262430 }
24272431
24282432 static void find_good_pkt_pointers(struct bpf_verifier_state *state,
2429− struct bpf_reg_state *dst_reg)
2433+ struct bpf_reg_state *dst_reg,
2434+ bool range_right_open)
24302435 {
24312436 struct bpf_reg_state *regs = state->regs, *reg;
2437+ u16 new_range;
24322438 int i;
24332439
2434− if (dst_reg->off < 0)
2440+ if (dst_reg->off < 0 ||
2441+ (dst_reg->off == 0 && range_right_open))
24352442 /* This doesn't give us any range */
24362443 return;
24372444
@@ -2442,9 +2449,13 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 4 unmodified lines
24422449 */
24432450 return;
24442451
2445− /* LLVM can generate four kind of checks:
2452+ new_range = dst_reg->off;
2453+ if (range_right_open)
2454+ new_range--;
2455+
2456+ /* Examples for register markings:
24462457 *
2447− * Type 1/2:
2458+ * pkt_data in dst register:
24482459 *
24492460 * r2 = r3;
24502461 * r2 += 8;
@@ -2461,7 +2472,7 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 10 unmodified lines
24612472 * r2=pkt(id=n,off=8,r=0)
24622473 * r3=pkt(id=n,off=0,r=0)
24632474 *
2464− * Type 3/4:
2475+ * pkt_data in src register:
24652476 *
24662477 * r2 = r3;
24672478 * r2 += 8;
@@ -2479,7 +2490,9 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 11 unmodified lines
24792490 * r3=pkt(id=n,off=0,r=0)
24802491 *
24812492 * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)
2482− * so that range of bytes [r3, r3 + 8) is safe to access.
2493+ * or r3=pkt(id=n,off=0,r=8-1), so that range of bytes [r3, r3 + 8)
2494+ * and [r3, r3 + 8-1) respectively is safe to access depending on
2495+ * the check.
24832496 */
24842497
24852498 /* If our ids match, then we must have the same max_value. And we
@@ -2490,14 +2503,14 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 4 unmodified lines
24902503 for (i = 0; i < MAX_BPF_REG; i++)
24912504 if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id)
24922505 /* keep the maximum range already checked */
2493− regs[i].range = max_t(u16, regs[i].range, dst_reg->off);
2506+ regs[i].range = max(regs[i].range, new_range);
24942507
24952508 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {
24962509 if (state->stack_slot_type[i] != STACK_SPILL)
24972510 continue;
24982511 reg = &state->spilled_regs[i / BPF_REG_SIZE];
24992512 if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id)
2500− reg->range = max_t(u16, reg->range, dst_reg->off);
2513+ reg->range = max(reg->range, new_range);
25012514 }
25022515 }
25032516
@@ -2861,19 +2874,43 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, · 357 unmodified lines
28612874 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&
28622875 dst_reg->type == PTR_TO_PACKET &&
28632876 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2864− find_good_pkt_pointers(this_branch, dst_reg);
2877+ /* pkt_data' > pkt_end */
2878+ find_good_pkt_pointers(this_branch, dst_reg, false);
2879+ } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&
2880+ dst_reg->type == PTR_TO_PACKET_END &&
2881+ regs[insn->src_reg].type == PTR_TO_PACKET) {
2882+ /* pkt_end > pkt_data' */
2883+ find_good_pkt_pointers(other_branch, &regs[insn->src_reg], true);
28652884 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&
28662885 dst_reg->type == PTR_TO_PACKET &&
28672886 regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2868− find_good_pkt_pointers(other_branch, dst_reg);
2887+ /* pkt_data' < pkt_end */
2888+ find_good_pkt_pointers(other_branch, dst_reg, true);
2889+ } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&
2890+ dst_reg->type == PTR_TO_PACKET_END &&
2891+ regs[insn->src_reg].type == PTR_TO_PACKET) {
2892+ /* pkt_end < pkt_data' */
2893+ find_good_pkt_pointers(this_branch, &regs[insn->src_reg], false);
2894+ } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&
2895+ dst_reg->type == PTR_TO_PACKET &&
2896+ regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2897+ /* pkt_data' >= pkt_end */
2898+ find_good_pkt_pointers(this_branch, dst_reg, true);
28692899 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&
28702900 dst_reg->type == PTR_TO_PACKET_END &&
28712901 regs[insn->src_reg].type == PTR_TO_PACKET) {
2872− find_good_pkt_pointers(other_branch, &regs[insn->src_reg]);
2902+ /* pkt_end >= pkt_data' */
2903+ find_good_pkt_pointers(other_branch, &regs[insn->src_reg], false);
2904+ } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&
2905+ dst_reg->type == PTR_TO_PACKET &&
2906+ regs[insn->src_reg].type == PTR_TO_PACKET_END) {
2907+ /* pkt_data' <= pkt_end */
2908+ find_good_pkt_pointers(other_branch, dst_reg, false);
28732909 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&
28742910 dst_reg->type == PTR_TO_PACKET_END &&
28752911 regs[insn->src_reg].type == PTR_TO_PACKET) {
2876− find_good_pkt_pointers(this_branch, &regs[insn->src_reg]);
2912+ /* pkt_end <= pkt_data' */
2913+ find_good_pkt_pointers(this_branch, &regs[insn->src_reg], true);
28772914 } else if (is_pointer_value(env, insn->dst_reg)) {
28782915 verbose("R%d pointer comparison prohibited\n", insn->dst_reg);
28792916 return -EACCES;
lib/ts_fsm.c+1−1
@@ -11,7 +11,7 @@ · 10 unmodified lines
1111 * ==========================================================================
1212 *
1313 * A finite state machine consists of n states (struct ts_fsm_token)
14− * representing the pattern as a finite automation. The data is read
14+ * representing the pattern as a finite automaton. The data is read
1515 * sequentially on an octet basis. Every state token specifies the number
1616 * of recurrences and the type of value accepted which can be either a
1717 * specific character or ctype based set of characters. The available
lib/ts_kmp.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 *
2828 * [1] Cormen, Leiserson, Rivest, Stein
2929 * Introdcution to Algorithms, 2nd Edition, MIT Press
30− * [2] See finite automation theory
30+ * [2] See finite automaton theory
3131 */
3232
3333 #include <linux/module.h>
mm/memcontrol.c+0−15
@@ -5828,21 +5828,6 @@ void mem_cgroup_sk_alloc(struct sock *sk) · 5827 unmodified lines
58285828 if (!mem_cgroup_sockets_enabled)
58295829 return;
58305830
5831− /*
5832− * Socket cloning can throw us here with sk_memcg already
5833− * filled. It won't however, necessarily happen from
5834− * process context. So the test for root memcg given
5835− * the current task's memcg won't help us in this case.
5836− *
5837− * Respecting the original socket's memcg is a better
5838− * decision in this case.
5839− */
5840− if (sk->sk_memcg) {
5841− BUG_ON(mem_cgroup_is_root(sk->sk_memcg));
5842− css_get(&sk->sk_memcg->css);
5843− return;
5844− }
5845−
58465831 rcu_read_lock();
58475832 memcg = mem_cgroup_from_task(current);
58485833 if (memcg == root_mem_cgroup)
mm/percpu.c+10−5
@@ -1329,7 +1329,9 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr) · 1328 unmodified lines
13291329 * @gfp: allocation flags
13301330 *
13311331 * Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't
1332− * contain %GFP_KERNEL, the allocation is atomic.
1332+ * contain %GFP_KERNEL, the allocation is atomic. If @gfp has __GFP_NOWARN
1333+ * then no warning will be triggered on invalid or failed allocation
1334+ * requests.
13331335 *
13341336 * RETURNS:
13351337 * Percpu pointer to the allocated area on success, NULL on failure.
@@ -1337,10 +1339,11 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr) · 1 unmodified line
13371339 static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
13381340 gfp_t gfp)
13391341 {
1342+ bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
1343+ bool do_warn = !(gfp & __GFP_NOWARN);
13401344 static int warn_limit = 10;
13411345 struct pcpu_chunk *chunk;
13421346 const char *err;
1343− bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
13441347 int slot, off, cpu, ret;
13451348 unsigned long flags;
13461349 void __percpu *ptr;
@@ -1361,7 +1364,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, · 14 unmodified lines
13611364
13621365 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||
13631366 !is_power_of_2(align))) {
1364− WARN(true, "illegal size (%zu) or align (%zu) for percpu allocation\n",
1367+ WARN(do_warn, "illegal size (%zu) or align (%zu) for percpu allocation\n",
13651368 size, align);
13661369 return NULL;
13671370 }
@@ -1482,7 +1485,7 @@ fail_unlock: · 114 unmodified lines
14821485 fail:
14831486 trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
14841487
1485− if (!is_atomic && warn_limit) {
1488+ if (!is_atomic && do_warn && warn_limit) {
14861489 pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
14871490 size, align, is_atomic, err);
14881491 dump_stack();
@@ -1507,7 +1510,9 @@ fail: · 18 unmodified lines
15071510 *
15081511 * Allocate zero-filled percpu area of @size bytes aligned at @align. If
15091512 * @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can
1510− * be called from any context but is a lot more likely to fail.
1513+ * be called from any context but is a lot more likely to fail. If @gfp
1514+ * has __GFP_NOWARN then no warning will be triggered on invalid or failed
1515+ * allocation requests.
15111516 *
15121517 * RETURNS:
15131518 * Percpu pointer to the allocated area on success, NULL on failure.
net/bridge/br_netlink.c+1−1
@@ -573,7 +573,7 @@ static int br_process_vlan_info(struct net_bridge *br, · 572 unmodified lines
573573 }
574574 *vinfo_last = NULL;
575575
576− return 0;
576+ return err;
577577 }
578578
579579 return br_vlan_info(br, p, cmd, vinfo_curr);
net/can/af_can.c+16−4
@@ -78,7 +78,7 @@ MODULE_PARM_DESC(stats_timer, "enable timer for statistics (default:on)"); · 77 unmodified lines
7878 static struct kmem_cache *rcv_cache __read_mostly;
7979
8080 /* table of registered CAN protocols */
81−static const struct can_proto *proto_tab[CAN_NPROTO] __read_mostly;
81+static const struct can_proto __rcu *proto_tab[CAN_NPROTO] __read_mostly;
8282 static DEFINE_MUTEX(proto_tab_lock);
8383
8484 static atomic_t skbcounter = ATOMIC_INIT(0);
@@ -788,7 +788,7 @@ int can_proto_register(const struct can_proto *cp) · 703 unmodified lines
788788
789789 mutex_lock(&proto_tab_lock);
790790
791− if (proto_tab[proto]) {
791+ if (rcu_access_pointer(proto_tab[proto])) {
792792 pr_err("can: protocol %d already registered\n", proto);
793793 err = -EBUSY;
794794 } else
@@ -812,7 +812,7 @@ void can_proto_unregister(const struct can_proto *cp) · 17 unmodified lines
812812 int proto = cp->protocol;
813813
814814 mutex_lock(&proto_tab_lock);
815− BUG_ON(proto_tab[proto] != cp);
815+ BUG_ON(rcu_access_pointer(proto_tab[proto]) != cp);
816816 RCU_INIT_POINTER(proto_tab[proto], NULL);
817817 mutex_unlock(&proto_tab_lock);
818818
@@ -875,9 +875,14 @@ static int can_pernet_init(struct net *net) · 56 unmodified lines
875875 spin_lock_init(&net->can.can_rcvlists_lock);
876876 net->can.can_rx_alldev_list =
877877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
878−
878+ if (!net->can.can_rx_alldev_list)
879+ goto out;
879880 net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL);
881+ if (!net->can.can_stats)
882+ goto out_free_alldev_list;
880883 net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL);
884+ if (!net->can.can_pstats)
885+ goto out_free_can_stats;
881886
882887 if (IS_ENABLED(CONFIG_PROC_FS)) {
883888 /* the statistics are updated every second (timer triggered) */
@@ -892,6 +897,13 @@ static int can_pernet_init(struct net *net) · 8 unmodified lines
892897 }
893898
894899 return 0;
900+
901+ out_free_can_stats:
902+ kfree(net->can.can_stats);
903+ out_free_alldev_list:
904+ kfree(net->can.can_rx_alldev_list);
905+ out:
906+ return -ENOMEM;
895907 }
896908
897909 static void can_pernet_exit(struct net *net)
net/can/bcm.c+3−2
@@ -1493,13 +1493,14 @@ static int bcm_init(struct sock *sk) · 1492 unmodified lines
14931493 static int bcm_release(struct socket *sock)
14941494 {
14951495 struct sock *sk = sock->sk;
1496− struct net *net = sock_net(sk);
1496+ struct net *net;
14971497 struct bcm_sock *bo;
14981498 struct bcm_op *op, *next;
14991499
1500− if (sk == NULL)
1500+ if (!sk)
15011501 return 0;
15021502
1503+ net = sock_net(sk);
15031504 bo = bcm_sk(sk);
15041505
15051506 /* remove bcm_ops, timer, rx_unregister(), etc. */
net/core/dev.c+3−3
@@ -1147,9 +1147,8 @@ static int dev_alloc_name_ns(struct net *net, · 1146 unmodified lines
11471147 return ret;
11481148 }
11491149
1150−static int dev_get_valid_name(struct net *net,
1151− struct net_device *dev,
1152− const char *name)
1150+int dev_get_valid_name(struct net *net, struct net_device *dev,
1151+ const char *name)
11531152 {
11541153 BUG_ON(!net);
11551154
@@ -1165,6 +1164,7 @@ static int dev_get_valid_name(struct net *net, · 9 unmodified lines
11651164
11661165 return 0;
11671166 }
1167+EXPORT_SYMBOL(dev_get_valid_name);
11681168
11691169 /**
11701170 * dev_change_name - change name of a device
net/core/dev_ioctl.c+12−1
@@ -303,7 +303,18 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) · 302 unmodified lines
303303 case SIOCSIFTXQLEN:
304304 if (ifr->ifr_qlen < 0)
305305 return -EINVAL;
306− dev->tx_queue_len = ifr->ifr_qlen;
306+ if (dev->tx_queue_len ^ ifr->ifr_qlen) {
307+ unsigned int orig_len = dev->tx_queue_len;
308+
309+ dev->tx_queue_len = ifr->ifr_qlen;
310+ err = call_netdevice_notifiers(
311+ NETDEV_CHANGE_TX_QUEUE_LEN, dev);
312+ err = notifier_to_errno(err);
313+ if (err) {
314+ dev->tx_queue_len = orig_len;
315+ return err;
316+ }
317+ }
307318 return 0;
308319
309320 case SIOCSIFNAME:
net/core/ethtool.c+2−3
@@ -436,7 +436,7 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, · 435 unmodified lines
436436 EXPORT_SYMBOL(ethtool_convert_link_mode_to_legacy_u32);
437437
438438 /* return false if legacy contained non-0 deprecated fields
439− * transceiver/maxtxpkt/maxrxpkt. rest of ksettings always updated
439+ * maxtxpkt/maxrxpkt. rest of ksettings always updated
440440 */
441441 static bool
442442 convert_legacy_settings_to_link_ksettings(
@@ -451,8 +451,7 @@ convert_legacy_settings_to_link_ksettings( · 8 unmodified lines
451451 * deprecated legacy fields, and they should not use
452452 * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS
453453 */
454− if (legacy_settings->transceiver ||
455− legacy_settings->maxtxpkt ||
454+ if (legacy_settings->maxtxpkt ||
456455 legacy_settings->maxrxpkt)
457456 retval = false;
458457
net/core/filter.c+16−15
@@ -1839,31 +1839,31 @@ static const struct bpf_func_proto bpf_redirect_proto = { · 1838 unmodified lines
18391839 .arg2_type = ARG_ANYTHING,
18401840 };
18411841
1842−BPF_CALL_3(bpf_sk_redirect_map, struct bpf_map *, map, u32, key, u64, flags)
1842+BPF_CALL_4(bpf_sk_redirect_map, struct sk_buff *, skb,
1843+ struct bpf_map *, map, u32, key, u64, flags)
18431844 {
1844− struct redirect_info *ri = this_cpu_ptr(&redirect_info);
1845+ struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
18451846
18461847 if (unlikely(flags))
18471848 return SK_ABORTED;
18481849
1849− ri->ifindex = key;
1850− ri->flags = flags;
1851− ri->map = map;
1850+ tcb->bpf.key = key;
1851+ tcb->bpf.flags = flags;
1852+ tcb->bpf.map = map;
18521853
18531854 return SK_REDIRECT;
18541855 }
18551856
1856−struct sock *do_sk_redirect_map(void)
1857+struct sock *do_sk_redirect_map(struct sk_buff *skb)
18571858 {
1858− struct redirect_info *ri = this_cpu_ptr(&redirect_info);
1859+ struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
18591860 struct sock *sk = NULL;
18601861
1861− if (ri->map) {
1862− sk = __sock_map_lookup_elem(ri->map, ri->ifindex);
1862+ if (tcb->bpf.map) {
1863+ sk = __sock_map_lookup_elem(tcb->bpf.map, tcb->bpf.key);
18631864
1864− ri->ifindex = 0;
1865− ri->map = NULL;
1866− /* we do not clear flags for future lookup */
1865+ tcb->bpf.key = 0;
1866+ tcb->bpf.map = NULL;
18671867 }
18681868
18691869 return sk;
@@ -1873,9 +1873,10 @@ static const struct bpf_func_proto bpf_sk_redirect_map_proto = { · 3 unmodified lines
18731873 .func = bpf_sk_redirect_map,
18741874 .gpl_only = false,
18751875 .ret_type = RET_INTEGER,
1876− .arg1_type = ARG_CONST_MAP_PTR,
1877− .arg2_type = ARG_ANYTHING,
1876+ .arg1_type = ARG_PTR_TO_CTX,
1877+ .arg2_type = ARG_CONST_MAP_PTR,
18781878 .arg3_type = ARG_ANYTHING,
1879+ .arg4_type = ARG_ANYTHING,
18791880 };
18801881
18811882 BPF_CALL_1(bpf_get_cgroup_classid, const struct sk_buff *, skb)
@@ -3683,7 +3684,6 @@ static bool sk_skb_is_valid_access(int off, int size, · 1801 unmodified lines
36833684 {
36843685 if (type == BPF_WRITE) {
36853686 switch (off) {
3686− case bpf_ctx_range(struct __sk_buff, mark):
36873687 case bpf_ctx_range(struct __sk_buff, tc_index):
36883688 case bpf_ctx_range(struct __sk_buff, priority):
36893689 break;
@@ -3693,6 +3693,7 @@ static bool sk_skb_is_valid_access(int off, int size, · 3 unmodified lines
36933693 }
36943694
36953695 switch (off) {
3696+ case bpf_ctx_range(struct __sk_buff, mark):
36963697 case bpf_ctx_range(struct __sk_buff, tc_classid):
36973698 return false;
36983699 case bpf_ctx_range(struct __sk_buff, data):
net/core/rtnetlink.c+10−3
@@ -1483,7 +1483,10 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { · 1482 unmodified lines
14831483 [IFLA_LINKINFO] = { .type = NLA_NESTED },
14841484 [IFLA_NET_NS_PID] = { .type = NLA_U32 },
14851485 [IFLA_NET_NS_FD] = { .type = NLA_U32 },
1486− [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 },
1486+ /* IFLA_IFALIAS is a string, but policy is set to NLA_BINARY to
1487+ * allow 0-length string (needed to remove an alias).
1488+ */
1489+ [IFLA_IFALIAS] = { .type = NLA_BINARY, .len = IFALIASZ - 1 },
14871490 [IFLA_VFINFO_LIST] = {. type = NLA_NESTED },
14881491 [IFLA_VF_PORTS] = { .type = NLA_NESTED },
14891492 [IFLA_PORT_SELF] = { .type = NLA_NESTED },
@@ -2093,7 +2096,7 @@ static int do_setlink(const struct sk_buff *skb, · 603 unmodified lines
20932096 dev->tx_queue_len = orig_len;
20942097 goto errout;
20952098 }
2096− status |= DO_SETLINK_NOTIFY;
2099+ status |= DO_SETLINK_MODIFIED;
20972100 }
20982101 }
20992102
@@ -2248,7 +2251,7 @@ static int do_setlink(const struct sk_buff *skb, · 148 unmodified lines
22482251
22492252 errout:
22502253 if (status & DO_SETLINK_MODIFIED) {
2251− if (status & DO_SETLINK_NOTIFY)
2254+ if ((status & DO_SETLINK_NOTIFY) == DO_SETLINK_NOTIFY)
22522255 netdev_state_change(dev);
22532256
22542257 if (err < 0)
@@ -4279,13 +4282,17 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi · 2024 unmodified lines
42794282
42804283 switch (event) {
42814284 case NETDEV_REBOOT:
4285+ case NETDEV_CHANGEMTU:
42824286 case NETDEV_CHANGEADDR:
42834287 case NETDEV_CHANGENAME:
42844288 case NETDEV_FEAT_CHANGE:
42854289 case NETDEV_BONDING_FAILOVER:
4290+ case NETDEV_POST_TYPE_CHANGE:
42864291 case NETDEV_NOTIFY_PEERS:
4292+ case NETDEV_CHANGEUPPER:
42874293 case NETDEV_RESEND_IGMP:
42884294 case NETDEV_CHANGEINFODATA:
4295+ case NETDEV_CHANGE_TX_QUEUE_LEN:
42894296 rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event),
42904297 GFP_KERNEL);
42914298 break;
net/core/skbuff.c+5−1
@@ -1124,9 +1124,13 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb, · 1123 unmodified lines
11241124
11251125 err = __zerocopy_sg_from_iter(sk, skb, &msg->msg_iter, len);
11261126 if (err == -EFAULT || (err == -EMSGSIZE && skb->len == orig_len)) {
1127+ struct sock *save_sk = skb->sk;
1128+
11271129 /* Streams do not free skb on error. Reset to prev state. */
11281130 msg->msg_iter = orig_iter;
1131+ skb->sk = sk;
11291132 ___pskb_trim(skb, orig_len);
1133+ skb->sk = save_sk;
11301134 return err;
11311135 }
11321136
@@ -1896,7 +1900,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta) · 763 unmodified lines
18961900 }
18971901
18981902 /* If we need update frag list, we are in troubles.
1899− * Certainly, it possible to add an offset to skb data,
1903+ * Certainly, it is possible to add an offset to skb data,
19001904 * but taking into account that pulling is expected to
19011905 * be very rare operation, it is worth to fight against
19021906 * further bloating skb head and crucify ourselves here instead.
net/core/sock.c+5−3
@@ -1677,12 +1677,17 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) · 1676 unmodified lines
16771677 newsk->sk_dst_pending_confirm = 0;
16781678 newsk->sk_wmem_queued = 0;
16791679 newsk->sk_forward_alloc = 0;
1680+
1681+ /* sk->sk_memcg will be populated at accept() time */
1682+ newsk->sk_memcg = NULL;
1683+
16801684 atomic_set(&newsk->sk_drops, 0);
16811685 newsk->sk_send_head = NULL;
16821686 newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;
16831687 atomic_set(&newsk->sk_zckey, 0);
16841688
16851689 sock_reset_flag(newsk, SOCK_DONE);
1690+ cgroup_sk_alloc(&newsk->sk_cgrp_data);
16861691
16871692 rcu_read_lock();
16881693 filter = rcu_dereference(sk->sk_filter);
@@ -1714,9 +1719,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) · 25 unmodified lines
17141719 newsk->sk_incoming_cpu = raw_smp_processor_id();
17151720 atomic64_set(&newsk->sk_cookie, 0);
17161721
1717− mem_cgroup_sk_alloc(newsk);
1718− cgroup_sk_alloc(&newsk->sk_cgrp_data);
1719−
17201722 /*
17211723 * Before updating sk_refcnt, we must commit prior changes to memory
17221724 * (Documentation/RCU/rculist_nulls.txt for details)
net/core/sock_reuseport.c+9−3
@@ -36,9 +36,14 @@ int reuseport_alloc(struct sock *sk) · 35 unmodified lines
3636 * soft irq of receive path or setsockopt from process context
3737 */
3838 spin_lock_bh(&reuseport_lock);
39− WARN_ONCE(rcu_dereference_protected(sk->sk_reuseport_cb,
40− lockdep_is_held(&reuseport_lock)),
41− "multiple allocations for the same socket");
39+
40+ /* Allocation attempts can occur concurrently via the setsockopt path
41+ * and the bind/hash path. Nothing to do when we lose the race.
42+ */
43+ if (rcu_dereference_protected(sk->sk_reuseport_cb,
44+ lockdep_is_held(&reuseport_lock)))
45+ goto out;
46+
4247 reuse = __reuseport_alloc(INIT_SOCKS);
4348 if (!reuse) {
4449 spin_unlock_bh(&reuseport_lock);
@@ -49,6 +54,7 @@ int reuseport_alloc(struct sock *sk) · 4 unmodified lines
4954 reuse->num_socks = 1;
5055 rcu_assign_pointer(sk->sk_reuseport_cb, reuse);
5156
57+out:
5258 spin_unlock_bh(&reuseport_lock);
5359
5460 return 0;
net/dccp/ipv4.c+8−5
@@ -414,8 +414,7 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk, · 413 unmodified lines
414414 sk_daddr_set(newsk, ireq->ir_rmt_addr);
415415 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
416416 newinet->inet_saddr = ireq->ir_loc_addr;
417− newinet->inet_opt = ireq->opt;
418− ireq->opt = NULL;
417+ RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt));
419418 newinet->mc_index = inet_iif(skb);
420419 newinet->mc_ttl = ip_hdr(skb)->ttl;
421420 newinet->inet_id = jiffies;
@@ -430,7 +429,10 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk, · 8 unmodified lines
430429 if (__inet_inherit_port(sk, newsk) < 0)
431430 goto put_and_exit;
432431 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
433−
432+ if (*own_req)
433+ ireq->ireq_opt = NULL;
434+ else
435+ newinet->inet_opt = NULL;
434436 return newsk;
435437
436438 exit_overflow:
@@ -441,6 +443,7 @@ exit: · 4 unmodified lines
441443 __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);
442444 return NULL;
443445 put_and_exit:
446+ newinet->inet_opt = NULL;
444447 inet_csk_prepare_forced_close(newsk);
445448 dccp_done(newsk);
446449 goto exit;
@@ -492,7 +495,7 @@ static int dccp_v4_send_response(const struct sock *sk, struct request_sock *req · 45 unmodified lines
492495 ireq->ir_rmt_addr);
493496 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
494497 ireq->ir_rmt_addr,
495− ireq->opt);
498+ rcu_dereference(ireq->ireq_opt));
496499 err = net_xmit_eval(err);
497500 }
498501
@@ -548,7 +551,7 @@ out: · 49 unmodified lines
548551 static void dccp_v4_reqsk_destructor(struct request_sock *req)
549552 {
550553 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
551− kfree(inet_rsk(req)->opt);
554+ kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
552555 }
553556
554557 void dccp_syn_ack_timeout(const struct request_sock *req)
net/ipv4/Kconfig+3−5
@@ -70,11 +70,9 @@ config IP_MULTIPLE_TABLES · 69 unmodified lines
7070 address into account. Furthermore, the TOS (Type-Of-Service) field
7171 of the packet can be used for routing decisions as well.
7272
73− If you are interested in this, please see the preliminary
74− documentation at <http://www.compendium.com.ar/policy-routing.txt>
75− and <ftp://post.tepkom.ru/pub/vol2/Linux/docs/advanced-routing.tex>.
76− You will need supporting software from
77− <ftp://ftp.tux.org/pub/net/ip-routing/>.
73+ If you need more information, see the Linux Advanced
74+ Routing and Traffic Control documentation at
75+ <http://lartc.org/howto/lartc.rpdb.html>
7876
7977 If unsure, say N.
8078
net/ipv4/cipso_ipv4.c+7−17
@@ -1951,7 +1951,7 @@ int cipso_v4_req_setattr(struct request_sock *req, · 1950 unmodified lines
19511951 buf = NULL;
19521952
19531953 req_inet = inet_rsk(req);
1954− opt = xchg(&req_inet->opt, opt);
1954+ opt = xchg((__force struct ip_options_rcu **)&req_inet->ireq_opt, opt);
19551955 if (opt)
19561956 kfree_rcu(opt, rcu);
19571957
@@ -1973,11 +1973,13 @@ req_setattr_failure: · 15 unmodified lines
19731973 * values on failure.
19741974 *
19751975 */
1976−static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr)
1976+static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr)
19771977 {
1978+ struct ip_options_rcu *opt = rcu_dereference_protected(*opt_ptr, 1);
19781979 int hdr_delta = 0;
1979− struct ip_options_rcu *opt = *opt_ptr;
19801980
1981+ if (!opt || opt->opt.cipso == 0)
1982+ return 0;
19811983 if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) {
19821984 u8 cipso_len;
19831985 u8 cipso_off;
@@ -2039,14 +2041,10 @@ static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr) · 55 unmodified lines
20392041 */
20402042 void cipso_v4_sock_delattr(struct sock *sk)
20412043 {
2042− int hdr_delta;
2043− struct ip_options_rcu *opt;
20442044 struct inet_sock *sk_inet;
2045+ int hdr_delta;
20452046
20462047 sk_inet = inet_sk(sk);
2047− opt = rcu_dereference_protected(sk_inet->inet_opt, 1);
2048− if (!opt || opt->opt.cipso == 0)
2049− return;
20502048
20512049 hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);
20522050 if (sk_inet->is_icsk && hdr_delta > 0) {
@@ -2066,15 +2064,7 @@ void cipso_v4_sock_delattr(struct sock *sk) · 13 unmodified lines
20662064 */
20672065 void cipso_v4_req_delattr(struct request_sock *req)
20682066 {
2069− struct ip_options_rcu *opt;
2070− struct inet_request_sock *req_inet;
2071−
2072− req_inet = inet_rsk(req);
2073− opt = req_inet->opt;
2074− if (!opt || opt->opt.cipso == 0)
2075− return;
2076−
2077− cipso_v4_delopt(&req_inet->opt);
2067+ cipso_v4_delopt(&inet_rsk(req)->ireq_opt);
20782068 }
20792069
20802070 /**
net/ipv4/inet_connection_sock.c+4−5
@@ -475,6 +475,7 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern) · 474 unmodified lines
475475 }
476476 spin_unlock_bh(&queue->fastopenq.lock);
477477 }
478+ mem_cgroup_sk_alloc(newsk);
478479 out:
479480 release_sock(sk);
480481 if (req)
@@ -539,9 +540,10 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk, · 58 unmodified lines
539540 {
540541 const struct inet_request_sock *ireq = inet_rsk(req);
541542 struct net *net = read_pnet(&ireq->ireq_net);
542− struct ip_options_rcu *opt = ireq->opt;
543+ struct ip_options_rcu *opt;
543544 struct rtable *rt;
544545
546+ opt = rcu_dereference(ireq->ireq_opt);
545547 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
546548 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
547549 sk->sk_protocol, inet_sk_flowi_flags(sk),
@@ -575,10 +577,9 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk, · 27 unmodified lines
575577 struct flowi4 *fl4;
576578 struct rtable *rt;
577579
580+ opt = rcu_dereference(ireq->ireq_opt);
578581 fl4 = &newinet->cork.fl.u.ip4;
579582
580− rcu_read_lock();
581− opt = rcu_dereference(newinet->inet_opt);
582583 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
583584 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
584585 sk->sk_protocol, inet_sk_flowi_flags(sk),
@@ -591,13 +592,11 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk, · 6 unmodified lines
591592 goto no_route;
592593 if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)
593594 goto route_err;
594− rcu_read_unlock();
595595 return &rt->dst;
596596
597597 route_err:
598598 ip_rt_put(rt);
599599 no_route:
600− rcu_read_unlock();
601600 __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
602601 return NULL;
603602 }
net/ipv4/inet_hashtables.c+1−4
@@ -456,10 +456,7 @@ static int inet_reuseport_add_sock(struct sock *sk, · 455 unmodified lines
456456 return reuseport_add_sock(sk, sk2);
457457 }
458458
459− /* Initial allocation may have already happened via setsockopt */
460− if (!rcu_access_pointer(sk->sk_reuseport_cb))
461− return reuseport_alloc(sk);
462− return 0;
459+ return reuseport_alloc(sk);
463460 }
464461
465462 int __inet_hash(struct sock *sk, struct sock *osk)
net/ipv4/syncookies.c+1−1
@@ -355,7 +355,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) · 354 unmodified lines
355355 /* We throwed the options of the initial SYN away, so we hope
356356 * the ACK carries the same options again (see RFC1122 4.2.3.8)
357357 */
358− ireq->opt = tcp_v4_save_options(sock_net(sk), skb);
358+ RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(sock_net(sk), skb));
359359
360360 if (security_inet_conn_request(sk, skb, req)) {
361361 reqsk_free(req);
net/ipv4/tcp_input.c+1−1
@@ -6196,7 +6196,7 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops, · 6195 unmodified lines
61966196 struct inet_request_sock *ireq = inet_rsk(req);
61976197
61986198 kmemcheck_annotate_bitfield(ireq, flags);
6199− ireq->opt = NULL;
6199+ ireq->ireq_opt = NULL;
62006200 #if IS_ENABLED(CONFIG_IPV6)
62016201 ireq->pktopts = NULL;
62026202 #endif
net/ipv4/tcp_ipv4.c+13−9
@@ -877,7 +877,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, · 876 unmodified lines
877877
878878 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
879879 ireq->ir_rmt_addr,
880− ireq->opt);
880+ rcu_dereference(ireq->ireq_opt));
881881 err = net_xmit_eval(err);
882882 }
883883
@@ -889,7 +889,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, · 5 unmodified lines
889889 */
890890 static void tcp_v4_reqsk_destructor(struct request_sock *req)
891891 {
892− kfree(inet_rsk(req)->opt);
892+ kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
893893 }
894894
895895 #ifdef CONFIG_TCP_MD5SIG
@@ -1265,10 +1265,11 @@ static void tcp_v4_init_req(struct request_sock *req, · 369 unmodified lines
12651265 struct sk_buff *skb)
12661266 {
12671267 struct inet_request_sock *ireq = inet_rsk(req);
1268+ struct net *net = sock_net(sk_listener);
12681269
12691270 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
12701271 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
1271− ireq->opt = tcp_v4_save_options(sock_net(sk_listener), skb);
1272+ RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(net, skb));
12721273 }
12731274
12741275 static struct dst_entry *tcp_v4_route_req(const struct sock *sk,
@@ -1355,10 +1356,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, · 80 unmodified lines
13551356 sk_daddr_set(newsk, ireq->ir_rmt_addr);
13561357 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
13571358 newsk->sk_bound_dev_if = ireq->ir_iif;
1358− newinet->inet_saddr = ireq->ir_loc_addr;
1359− inet_opt = ireq->opt;
1360− rcu_assign_pointer(newinet->inet_opt, inet_opt);
1361− ireq->opt = NULL;
1359+ newinet->inet_saddr = ireq->ir_loc_addr;
1360+ inet_opt = rcu_dereference(ireq->ireq_opt);
1361+ RCU_INIT_POINTER(newinet->inet_opt, inet_opt);
13621362 newinet->mc_index = inet_iif(skb);
13631363 newinet->mc_ttl = ip_hdr(skb)->ttl;
13641364 newinet->rcv_tos = ip_hdr(skb)->tos;
@@ -1403,9 +1403,12 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, · 38 unmodified lines
14031403 if (__inet_inherit_port(sk, newsk) < 0)
14041404 goto put_and_exit;
14051405 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
1406− if (*own_req)
1406+ if (likely(*own_req)) {
14071407 tcp_move_syn(newtp, req);
1408−
1408+ ireq->ireq_opt = NULL;
1409+ } else {
1410+ newinet->inet_opt = NULL;
1411+ }
14091412 return newsk;
14101413
14111414 exit_overflow:
@@ -1416,6 +1419,7 @@ exit: · 4 unmodified lines
14161419 tcp_listendrop(sk);
14171420 return NULL;
14181421 put_and_exit:
1422+ newinet->inet_opt = NULL;
14191423 inet_csk_prepare_forced_close(newsk);
14201424 tcp_done(newsk);
14211425 goto exit;
net/ipv4/udp.c+3−6
@@ -231,10 +231,7 @@ static int udp_reuseport_add_sock(struct sock *sk, struct udp_hslot *hslot) · 230 unmodified lines
231231 }
232232 }
233233
234− /* Initial allocation may have already happened via setsockopt */
235− if (!rcu_access_pointer(sk->sk_reuseport_cb))
236− return reuseport_alloc(sk);
237− return 0;
234+ return reuseport_alloc(sk);
238235 }
239236
240237 /**
@@ -1061,7 +1058,7 @@ back_from_confirm: · 820 unmodified lines
10611058 /* ... which is an evident application bug. --ANK */
10621059 release_sock(sk);
10631060
1064− net_dbg_ratelimited("cork app bug 2\n");
1061+ net_dbg_ratelimited("socket already corked\n");
10651062 err = -EINVAL;
10661063 goto out;
10671064 }
@@ -1144,7 +1141,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, · 76 unmodified lines
11441141 if (unlikely(!up->pending)) {
11451142 release_sock(sk);
11461143
1147− net_dbg_ratelimited("udp cork app bug 3\n");
1144+ net_dbg_ratelimited("cork failed\n");
11481145 return -EINVAL;
11491146 }
11501147
net/ipv6/ip6_flowlabel.c+1−0
@@ -315,6 +315,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, · 314 unmodified lines
315315 }
316316 opt_space->dst1opt = fopt->dst1opt;
317317 opt_space->opt_flen = fopt->opt_flen;
318+ opt_space->tot_len = fopt->tot_len;
318319 return opt_space;
319320 }
320321 EXPORT_SYMBOL_GPL(fl6_merge_options);
net/ipv6/ip6_output.c+2−2
@@ -1161,11 +1161,11 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork, · 1160 unmodified lines
11611161 if (WARN_ON(v6_cork->opt))
11621162 return -EINVAL;
11631163
1164− v6_cork->opt = kzalloc(opt->tot_len, sk->sk_allocation);
1164+ v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
11651165 if (unlikely(!v6_cork->opt))
11661166 return -ENOBUFS;
11671167
1168− v6_cork->opt->tot_len = opt->tot_len;
1168+ v6_cork->opt->tot_len = sizeof(*opt);
11691169 v6_cork->opt->opt_flen = opt->opt_flen;
11701170 v6_cork->opt->opt_nflen = opt->opt_nflen;
11711171
net/l2tp/l2tp_ppp.c+3−0
@@ -988,6 +988,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, · 987 unmodified lines
988988 session->name, cmd, arg);
989989
990990 sk = ps->sock;
991+ if (!sk)
992+ return -EBADR;
993+
991994 sock_hold(sk);
992995
993996 switch (cmd) {
net/mac80211/key.c+17−4
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
55 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
66 * Copyright 2013-2014 Intel Mobile Communications GmbH
7− * Copyright 2015 Intel Deutschland GmbH
7+ * Copyright 2015-2017 Intel Deutschland GmbH
88 *
99 * This program is free software; you can redistribute it and/or modify
1010 * it under the terms of the GNU General Public License version 2 as
@@ -620,9 +620,6 @@ int ieee80211_key_link(struct ieee80211_key *key, · 609 unmodified lines
620620
621621 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
622622 idx = key->conf.keyidx;
623− key->local = sdata->local;
624− key->sdata = sdata;
625− key->sta = sta;
626623
627624 mutex_lock(&sdata->local->key_mtx);
628625
@@ -633,6 +630,21 @@ int ieee80211_key_link(struct ieee80211_key *key, · 4 unmodified lines
633630 else
634631 old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
635632
633+ /*
634+ * Silently accept key re-installation without really installing the
635+ * new version of the key to avoid nonce reuse or replay issues.
636+ */
637+ if (old_key && key->conf.keylen == old_key->conf.keylen &&
638+ !memcmp(key->conf.key, old_key->conf.key, key->conf.keylen)) {
639+ ieee80211_key_free_unused(key);
640+ ret = 0;
641+ goto out;
642+ }
643+
644+ key->local = sdata->local;
645+ key->sdata = sdata;
646+ key->sta = sta;
647+
636648 increment_tailroom_need_count(sdata);
637649
638650 ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -648,6 +660,7 @@ int ieee80211_key_link(struct ieee80211_key *key, · 9 unmodified lines
648660 ret = 0;
649661 }
650662
663+ out:
651664 mutex_unlock(&sdata->local->key_mtx);
652665
653666 return ret;
net/ncsi/internal.h+1−0
@@ -286,6 +286,7 @@ struct ncsi_dev_priv { · 285 unmodified lines
286286 struct work_struct work; /* For channel management */
287287 struct packet_type ptype; /* NCSI packet Rx handler */
288288 struct list_head node; /* Form NCSI device list */
289+#define NCSI_MAX_VLAN_VIDS 15
289290 struct list_head vlan_vids; /* List of active VLAN IDs */
290291 };
291292
net/ncsi/ncsi-aen.c+1−1
@@ -187,7 +187,7 @@ static struct ncsi_aen_handler { · 186 unmodified lines
187187 } ncsi_aen_handlers[] = {
188188 { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },
189189 { NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr },
190− { NCSI_PKT_AEN_HNCDSC, 4, ncsi_aen_handler_hncdsc }
190+ { NCSI_PKT_AEN_HNCDSC, 8, ncsi_aen_handler_hncdsc }
191191 };
192192
193193 int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
net/ncsi/ncsi-manage.c+33−19
@@ -189,6 +189,7 @@ static void ncsi_channel_monitor(unsigned long data) · 188 unmodified lines
189189 struct ncsi_channel *nc = (struct ncsi_channel *)data;
190190 struct ncsi_package *np = nc->package;
191191 struct ncsi_dev_priv *ndp = np->ndp;
192+ struct ncsi_channel_mode *ncm;
192193 struct ncsi_cmd_arg nca;
193194 bool enabled, chained;
194195 unsigned int monitor_state;
@@ -202,11 +203,15 @@ static void ncsi_channel_monitor(unsigned long data) · 7 unmodified lines
202203 monitor_state = nc->monitor.state;
203204 spin_unlock_irqrestore(&nc->lock, flags);
204205
205− if (!enabled || chained)
206+ if (!enabled || chained) {
207+ ncsi_stop_channel_monitor(nc);
206208 return;
209+ }
207210 if (state != NCSI_CHANNEL_INACTIVE &&
208− state != NCSI_CHANNEL_ACTIVE)
211+ state != NCSI_CHANNEL_ACTIVE) {
212+ ncsi_stop_channel_monitor(nc);
209213 return;
214+ }
210215
211216 switch (monitor_state) {
212217 case NCSI_CHANNEL_MONITOR_START:
@@ -217,28 +222,28 @@ static void ncsi_channel_monitor(unsigned long data) · 4 unmodified lines
217222 nca.type = NCSI_PKT_CMD_GLS;
218223 nca.req_flags = 0;
219224 ret = ncsi_xmit_cmd(&nca);
220− if (ret) {
225+ if (ret)
221226 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n",
222227 ret);
223− return;
224− }
225−
226228 break;
227229 case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:
228230 break;
229231 default:
230− if (!(ndp->flags & NCSI_DEV_HWA) &&
231− state == NCSI_CHANNEL_ACTIVE) {
232+ if (!(ndp->flags & NCSI_DEV_HWA)) {
232233 ncsi_report_link(ndp, true);
233234 ndp->flags |= NCSI_DEV_RESHUFFLE;
234235 }
235236
237+ ncsi_stop_channel_monitor(nc);
238+
239+ ncm = &nc->modes[NCSI_MODE_LINK];
236240 spin_lock_irqsave(&nc->lock, flags);
237241 nc->state = NCSI_CHANNEL_INVISIBLE;
242+ ncm->data[2] &= ~0x1;
238243 spin_unlock_irqrestore(&nc->lock, flags);
239244
240245 spin_lock_irqsave(&ndp->lock, flags);
241− nc->state = NCSI_CHANNEL_INACTIVE;
246+ nc->state = NCSI_CHANNEL_ACTIVE;
242247 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
243248 spin_unlock_irqrestore(&ndp->lock, flags);
244249 ncsi_process_next_channel(ndp);
@@ -732,6 +737,10 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, · 487 unmodified lines
732737 if (index < 0) {
733738 netdev_err(ndp->ndev.dev,
734739 "Failed to add new VLAN tag, error %d\n", index);
740+ if (index == -ENOSPC)
741+ netdev_err(ndp->ndev.dev,
742+ "Channel %u already has all VLAN filters set\n",
743+ nc->id);
735744 return -1;
736745 }
737746
@@ -998,12 +1007,15 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp) · 260 unmodified lines
9981007 struct ncsi_package *np;
9991008 struct ncsi_channel *nc;
10001009 unsigned int cap;
1010+ bool has_channel = false;
10011011
10021012 /* The hardware arbitration is disabled if any one channel
10031013 * doesn't support explicitly.
10041014 */
10051015 NCSI_FOR_EACH_PACKAGE(ndp, np) {
10061016 NCSI_FOR_EACH_CHANNEL(np, nc) {
1017+ has_channel = true;
1018+
10071019 cap = nc->caps[NCSI_CAP_GENERIC].cap;
10081020 if (!(cap & NCSI_CAP_GENERIC_HWA) ||
10091021 (cap & NCSI_CAP_GENERIC_HWA_MASK) !=
@@ -1014,8 +1026,13 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp) · 4 unmodified lines
10141026 }
10151027 }
10161028
1017− ndp->flags |= NCSI_DEV_HWA;
1018− return true;
1029+ if (has_channel) {
1030+ ndp->flags |= NCSI_DEV_HWA;
1031+ return true;
1032+ }
1033+
1034+ ndp->flags &= ~NCSI_DEV_HWA;
1035+ return false;
10191036 }
10201037
10211038 static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp)
@@ -1403,7 +1420,6 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp) · 381 unmodified lines
14031420
14041421 int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
14051422 {
1406− struct ncsi_channel_filter *ncf;
14071423 struct ncsi_dev_priv *ndp;
14081424 unsigned int n_vids = 0;
14091425 struct vlan_vid *vlan;
@@ -1420,7 +1436,6 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) · 10 unmodified lines
14201436 }
14211437
14221438 ndp = TO_NCSI_DEV_PRIV(nd);
1423− ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN];
14241439
14251440 /* Add the VLAN id to our internal list */
14261441 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {
@@ -1431,12 +1446,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) · 4 unmodified lines
14311446 return 0;
14321447 }
14331448 }
1434−
1435− if (n_vids >= ncf->total) {
1436− netdev_info(dev,
1437− "NCSI Channel supports up to %u VLAN tags but %u are already set\n",
1438− ncf->total, n_vids);
1439− return -EINVAL;
1449+ if (n_vids >= NCSI_MAX_VLAN_VIDS) {
1450+ netdev_warn(dev,
1451+ "tried to add vlan id %u but NCSI max already registered (%u)\n",
1452+ vid, NCSI_MAX_VLAN_VIDS);
1453+ return -ENOSPC;
14401454 }
14411455
14421456 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
net/ncsi/ncsi-rsp.c+1−1
@@ -959,7 +959,7 @@ static struct ncsi_rsp_handler { · 958 unmodified lines
959959 { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf },
960960 { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf },
961961 { NCSI_PKT_RSP_SNFC, 4, ncsi_rsp_handler_snfc },
962− { NCSI_PKT_RSP_GVI, 36, ncsi_rsp_handler_gvi },
962+ { NCSI_PKT_RSP_GVI, 40, ncsi_rsp_handler_gvi },
963963 { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc },
964964 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp },
965965 { NCSI_PKT_RSP_GCPS, 172, ncsi_rsp_handler_gcps },
net/netlink/af_netlink.c+4−4
@@ -2307,6 +2307,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 2306 unmodified lines
23072307 size_t tlvlen = 0;
23082308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
23092309 unsigned int flags = 0;
2310+ bool nlk_has_extack = nlk->flags & NETLINK_F_EXT_ACK;
23102311
23112312 /* Error messages get the original request appened, unless the user
23122313 * requests to cap the error message, and get extra error data if
@@ -2317,7 +2318,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 4 unmodified lines
23172318 payload += nlmsg_len(nlh);
23182319 else
23192320 flags |= NLM_F_CAPPED;
2320− if (nlk->flags & NETLINK_F_EXT_ACK && extack) {
2321+ if (nlk_has_extack && extack) {
23212322 if (extack->_msg)
23222323 tlvlen += nla_total_size(strlen(extack->_msg) + 1);
23232324 if (extack->bad_attr)
@@ -2326,8 +2327,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 2 unmodified lines
23262327 } else {
23272328 flags |= NLM_F_CAPPED;
23282329
2329− if (nlk->flags & NETLINK_F_EXT_ACK &&
2330− extack && extack->cookie_len)
2330+ if (nlk_has_extack && extack && extack->cookie_len)
23312331 tlvlen += nla_total_size(extack->cookie_len);
23322332 }
23332333
@@ -2355,7 +2355,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 21 unmodified lines
23552355 errmsg->error = err;
23562356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
23572357
2358− if (nlk->flags & NETLINK_F_EXT_ACK && extack) {
2358+ if (nlk_has_extack && extack) {
23592359 if (err) {
23602360 if (extack->_msg)
23612361 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,
net/packet/af_packet.c+16−8
@@ -1769,7 +1769,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) · 1768 unmodified lines
17691769
17701770 out:
17711771 if (err && rollover) {
1772− kfree(rollover);
1772+ kfree_rcu(rollover, rcu);
17731773 po->rollover = NULL;
17741774 }
17751775 mutex_unlock(&fanout_mutex);
@@ -1796,8 +1796,10 @@ static struct packet_fanout *fanout_release(struct sock *sk) · 20 unmodified lines
17961796 else
17971797 f = NULL;
17981798
1799− if (po->rollover)
1799+ if (po->rollover) {
18001800 kfree_rcu(po->rollover, rcu);
1801+ po->rollover = NULL;
1802+ }
18011803 }
18021804 mutex_unlock(&fanout_mutex);
18031805
@@ -3851,6 +3853,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, · 2047 unmodified lines
38513853 void *data = &val;
38523854 union tpacket_stats_u st;
38533855 struct tpacket_rollover_stats rstats;
3856+ struct packet_rollover *rollover;
38543857
38553858 if (level != SOL_PACKET)
38563859 return -ENOPROTOOPT;
@@ -3929,13 +3932,18 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, · 72 unmodified lines
39293932 0);
39303933 break;
39313934 case PACKET_ROLLOVER_STATS:
3932− if (!po->rollover)
3935+ rcu_read_lock();
3936+ rollover = rcu_dereference(po->rollover);
3937+ if (rollover) {
3938+ rstats.tp_all = atomic_long_read(&rollover->num);
3939+ rstats.tp_huge = atomic_long_read(&rollover->num_huge);
3940+ rstats.tp_failed = atomic_long_read(&rollover->num_failed);
3941+ data = &rstats;
3942+ lv = sizeof(rstats);
3943+ }
3944+ rcu_read_unlock();
3945+ if (!rollover)
39333946 return -EINVAL;
3934− rstats.tp_all = atomic_long_read(&po->rollover->num);
3935− rstats.tp_huge = atomic_long_read(&po->rollover->num_huge);
3936− rstats.tp_failed = atomic_long_read(&po->rollover->num_failed);
3937− data = &rstats;
3938− lv = sizeof(rstats);
39393947 break;
39403948 case PACKET_TX_HAS_OFF:
39413949 val = po->tp_tx_has_off;
net/rxrpc/af_rxrpc.c+3−2
@@ -308,10 +308,11 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock, · 307 unmodified lines
308308 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len,
309309 gfp);
310310 /* The socket has been unlocked. */
311− if (!IS_ERR(call))
311+ if (!IS_ERR(call)) {
312312 call->notify_rx = notify_rx;
313+ mutex_unlock(&call->user_mutex);
314+ }
313315
314− mutex_unlock(&call->user_mutex);
315316 _leave(" = %p", call);
316317 return call;
317318 }
net/sched/cls_flower.c+2−0
@@ -234,6 +234,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f) · 233 unmodified lines
234234 tc_cls_common_offload_init(&cls_flower.common, tp);
235235 cls_flower.command = TC_CLSFLOWER_DESTROY;
236236 cls_flower.cookie = (unsigned long) f;
237+ cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
237238
238239 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, &cls_flower);
239240 }
@@ -289,6 +290,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) · 49 unmodified lines
289290 cls_flower.command = TC_CLSFLOWER_STATS;
290291 cls_flower.cookie = (unsigned long) f;
291292 cls_flower.exts = &f->exts;
293+ cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
292294
293295 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,
294296 &cls_flower);
net/sctp/input.c+1−1
@@ -421,7 +421,7 @@ void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t, · 420 unmodified lines
421421 {
422422 struct dst_entry *dst;
423423
424− if (!t)
424+ if (sock_owned_by_user(sk) || !t)
425425 return;
426426 dst = sctp_transport_dst_check(t);
427427 if (dst)
net/sctp/socket.c+4−0
@@ -4906,6 +4906,10 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp) · 4905 unmodified lines
49064906 struct socket *sock;
49074907 int err = 0;
49084908
4909+ /* Do not peel off from one netns to another one. */
4910+ if (!net_eq(current->nsproxy->net_ns, sock_net(sk)))
4911+ return -EINVAL;
4912+
49094913 if (!asoc)
49104914 return -EINVAL;
49114915
net/vmw_vsock/hyperv_transport.c+18−4
@@ -310,11 +310,15 @@ static void hvs_close_connection(struct vmbus_channel *chan) · 309 unmodified lines
310310 struct sock *sk = get_per_channel_state(chan);
311311 struct vsock_sock *vsk = vsock_sk(sk);
312312
313+ lock_sock(sk);
314+
313315 sk->sk_state = SS_UNCONNECTED;
314316 sock_set_flag(sk, SOCK_DONE);
315317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN;
316318
317319 sk->sk_state_change(sk);
320+
321+ release_sock(sk);
318322 }
319323
320324 static void hvs_open_connection(struct vmbus_channel *chan)
@@ -344,6 +348,8 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 23 unmodified lines
344348 if (!sk)
345349 return;
346350
351+ lock_sock(sk);
352+
347353 if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) ||
348354 (!conn_from_host && sk->sk_state != SS_CONNECTING))
349355 goto out;
@@ -395,9 +401,7 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 45 unmodified lines
395401
396402 vsock_insert_connected(vnew);
397403
398− lock_sock(sk);
399404 vsock_enqueue_accept(sk, new);
400− release_sock(sk);
401405 } else {
402406 sk->sk_state = SS_CONNECTED;
403407 sk->sk_socket->state = SS_CONNECTED;
@@ -410,6 +414,8 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 6 unmodified lines
410414 out:
411415 /* Release refcnt obtained when we called vsock_find_bound_socket() */
412416 sock_put(sk);
417+
418+ release_sock(sk);
413419 }
414420
415421 static u32 hvs_get_local_cid(void)
@@ -476,13 +482,21 @@ out: · 60 unmodified lines
476482
477483 static void hvs_release(struct vsock_sock *vsk)
478484 {
485+ struct sock *sk = sk_vsock(vsk);
479486 struct hvsock *hvs = vsk->trans;
480− struct vmbus_channel *chan = hvs->chan;
487+ struct vmbus_channel *chan;
481488
489+ lock_sock(sk);
490+
491+ sk->sk_state = SS_DISCONNECTING;
492+ vsock_remove_sock(vsk);
493+
494+ release_sock(sk);
495+
496+ chan = hvs->chan;
482497 if (chan)
483498 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN);
484499
485− vsock_remove_sock(vsk);
486500 }
487501
488502 static void hvs_destruct(struct vsock_sock *vsk)
samples/sockmap/sockmap_kern.c+1−1
@@ -62,7 +62,7 @@ int bpf_prog2(struct __sk_buff *skb) · 61 unmodified lines
6262 ret = 1;
6363
6464 bpf_printk("sockmap: %d -> %d @ %d\n", lport, bpf_ntohl(rport), ret);
65− return bpf_sk_redirect_map(&sock_map, ret, 0);
65+ return bpf_sk_redirect_map(skb, &sock_map, ret, 0);
6666 }
6767
6868 SEC("sockops")
tools/include/uapi/linux/bpf.h+2−1
@@ -569,9 +569,10 @@ union bpf_attr { · 568 unmodified lines
569569 * @flags: reserved for future use
570570 * Return: 0 on success or negative error code
571571 *
572− * int bpf_sk_redirect_map(map, key, flags)
572+ * int bpf_sk_redirect_map(skb, map, key, flags)
573573 * Redirect skb to a sock in map using key as a lookup key for the
574574 * sock in map.
575+ * @skb: pointer to skb
575576 * @map: pointer to sockmap
576577 * @key: key to lookup sock in map
577578 * @flags: reserved for future use
tools/testing/selftests/bpf/bpf_helpers.h+1−1
@@ -65,7 +65,7 @@ static int (*bpf_xdp_adjust_head)(void *ctx, int offset) = · 64 unmodified lines
6565 static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval,
6666 int optlen) =
6767 (void *) BPF_FUNC_setsockopt;
68−static int (*bpf_sk_redirect_map)(void *map, int key, int flags) =
68+static int (*bpf_sk_redirect_map)(void *ctx, void *map, int key, int flags) =
6969 (void *) BPF_FUNC_sk_redirect_map;
7070 static int (*bpf_sock_map_update)(void *map, void *key, void *value,
7171 unsigned long long flags) =
tools/testing/selftests/bpf/sockmap_verdict_prog.c+2−2
@@ -61,8 +61,8 @@ int bpf_prog2(struct __sk_buff *skb) · 60 unmodified lines
6161 bpf_printk("verdict: data[0] = redir(%u:%u)\n", map, sk);
6262
6363 if (!map)
64− return bpf_sk_redirect_map(&sock_map_rx, sk, 0);
65− return bpf_sk_redirect_map(&sock_map_tx, sk, 0);
64+ return bpf_sk_redirect_map(skb, &sock_map_rx, sk, 0);
65+ return bpf_sk_redirect_map(skb, &sock_map_tx, sk, 0);
6666 }
6767
6868 char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/test_maps.c+11−1
@@ -466,7 +466,7 @@ static void test_sockmap(int tasks, void *data) · 465 unmodified lines
466466 int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc;
467467 struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break;
468468 int ports[] = {50200, 50201, 50202, 50204};
469− int err, i, fd, sfd[6] = {0xdeadbeef};
469+ int err, i, fd, udp, sfd[6] = {0xdeadbeef};
470470 u8 buf[20] = {0x0, 0x5, 0x3, 0x2, 0x1, 0x0};
471471 int parse_prog, verdict_prog;
472472 struct sockaddr_in addr;
@@ -548,6 +548,16 @@ static void test_sockmap(int tasks, void *data) · 75 unmodified lines
548548 goto out_sockmap;
549549 }
550550
551+ /* Test update with unsupported UDP socket */
552+ udp = socket(AF_INET, SOCK_DGRAM, 0);
553+ i = 0;
554+ err = bpf_map_update_elem(fd, &i, &udp, BPF_ANY);
555+ if (!err) {
556+ printf("Failed socket SOCK_DGRAM allowed '%i:%i'\n",
557+ i, udp);
558+ goto out_sockmap;
559+ }
560+
551561 /* Test update without programs */
552562 for (i = 0; i < 6; i++) {
553563 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY);
tools/testing/selftests/bpf/test_verifier.c+508−2
@@ -1130,15 +1130,27 @@ static struct bpf_test tests[] = { · 1129 unmodified lines
11301130 .errstr = "invalid bpf_context access",
11311131 },
11321132 {
1133− "check skb->mark is writeable by SK_SKB",
1133+ "invalid access of skb->mark for SK_SKB",
1134+ .insns = {
1135+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
1136+ offsetof(struct __sk_buff, mark)),
1137+ BPF_EXIT_INSN(),
1138+ },
1139+ .result = REJECT,
1140+ .prog_type = BPF_PROG_TYPE_SK_SKB,
1141+ .errstr = "invalid bpf_context access",
1142+ },
1143+ {
1144+ "check skb->mark is not writeable by SK_SKB",
11341145 .insns = {
11351146 BPF_MOV64_IMM(BPF_REG_0, 0),
11361147 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0,
11371148 offsetof(struct __sk_buff, mark)),
11381149 BPF_EXIT_INSN(),
11391150 },
1140− .result = ACCEPT,
1151+ .result = REJECT,
11411152 .prog_type = BPF_PROG_TYPE_SK_SKB,
1153+ .errstr = "invalid bpf_context access",
11421154 },
11431155 {
11441156 "check skb->tc_index is writeable by SK_SKB",
@@ -6645,6 +6657,500 @@ static struct bpf_test tests[] = { · 5500 unmodified lines
66456657 .errstr = "BPF_END uses reserved fields",
66466658 .result = REJECT,
66476659 },
6660+ {
6661+ "arithmetic ops make PTR_TO_CTX unusable",
6662+ .insns = {
6663+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1,
6664+ offsetof(struct __sk_buff, data) -
6665+ offsetof(struct __sk_buff, mark)),
6666+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
6667+ offsetof(struct __sk_buff, mark)),
6668+ BPF_EXIT_INSN(),
6669+ },
6670+ .errstr = "dereference of modified ctx ptr R1 off=68+8, ctx+const is allowed, ctx+const+const is not",
6671+ .result = REJECT,
6672+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
6673+ },
6674+ {
6675+ "XDP pkt read, pkt_end mangling, bad access 1",
6676+ .insns = {
6677+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6678+ offsetof(struct xdp_md, data)),
6679+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6680+ offsetof(struct xdp_md, data_end)),
6681+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6682+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6683+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 8),
6684+ BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6685+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6686+ BPF_MOV64_IMM(BPF_REG_0, 0),
6687+ BPF_EXIT_INSN(),
6688+ },
6689+ .errstr = "R1 offset is outside of the packet",
6690+ .result = REJECT,
6691+ .prog_type = BPF_PROG_TYPE_XDP,
6692+ },
6693+ {
6694+ "XDP pkt read, pkt_end mangling, bad access 2",
6695+ .insns = {
6696+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6697+ offsetof(struct xdp_md, data)),
6698+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6699+ offsetof(struct xdp_md, data_end)),
6700+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6701+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6702+ BPF_ALU64_IMM(BPF_SUB, BPF_REG_3, 8),
6703+ BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6704+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6705+ BPF_MOV64_IMM(BPF_REG_0, 0),
6706+ BPF_EXIT_INSN(),
6707+ },
6708+ .errstr = "R1 offset is outside of the packet",
6709+ .result = REJECT,
6710+ .prog_type = BPF_PROG_TYPE_XDP,
6711+ },
6712+ {
6713+ "XDP pkt read, pkt_data' > pkt_end, good access",
6714+ .insns = {
6715+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6716+ offsetof(struct xdp_md, data)),
6717+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6718+ offsetof(struct xdp_md, data_end)),
6719+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6720+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6721+ BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6722+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6723+ BPF_MOV64_IMM(BPF_REG_0, 0),
6724+ BPF_EXIT_INSN(),
6725+ },
6726+ .result = ACCEPT,
6727+ .prog_type = BPF_PROG_TYPE_XDP,
6728+ },
6729+ {
6730+ "XDP pkt read, pkt_data' > pkt_end, bad access 1",
6731+ .insns = {
6732+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6733+ offsetof(struct xdp_md, data)),
6734+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6735+ offsetof(struct xdp_md, data_end)),
6736+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6737+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6738+ BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1),
6739+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
6740+ BPF_MOV64_IMM(BPF_REG_0, 0),
6741+ BPF_EXIT_INSN(),
6742+ },
6743+ .errstr = "R1 offset is outside of the packet",
6744+ .result = REJECT,
6745+ .prog_type = BPF_PROG_TYPE_XDP,
6746+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6747+ },
6748+ {
6749+ "XDP pkt read, pkt_data' > pkt_end, bad access 2",
6750+ .insns = {
6751+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6752+ offsetof(struct xdp_md, data)),
6753+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6754+ offsetof(struct xdp_md, data_end)),
6755+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6756+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6757+ BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 0),
6758+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6759+ BPF_MOV64_IMM(BPF_REG_0, 0),
6760+ BPF_EXIT_INSN(),
6761+ },
6762+ .errstr = "R1 offset is outside of the packet",
6763+ .result = REJECT,
6764+ .prog_type = BPF_PROG_TYPE_XDP,
6765+ },
6766+ {
6767+ "XDP pkt read, pkt_end > pkt_data', good access",
6768+ .insns = {
6769+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6770+ offsetof(struct xdp_md, data)),
6771+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6772+ offsetof(struct xdp_md, data_end)),
6773+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6774+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6775+ BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6776+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6777+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6778+ BPF_MOV64_IMM(BPF_REG_0, 0),
6779+ BPF_EXIT_INSN(),
6780+ },
6781+ .result = ACCEPT,
6782+ .prog_type = BPF_PROG_TYPE_XDP,
6783+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6784+ },
6785+ {
6786+ "XDP pkt read, pkt_end > pkt_data', bad access 1",
6787+ .insns = {
6788+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6789+ offsetof(struct xdp_md, data)),
6790+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6791+ offsetof(struct xdp_md, data_end)),
6792+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6793+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6794+ BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6795+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6796+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6797+ BPF_MOV64_IMM(BPF_REG_0, 0),
6798+ BPF_EXIT_INSN(),
6799+ },
6800+ .errstr = "R1 offset is outside of the packet",
6801+ .result = REJECT,
6802+ .prog_type = BPF_PROG_TYPE_XDP,
6803+ },
6804+ {
6805+ "XDP pkt read, pkt_end > pkt_data', bad access 2",
6806+ .insns = {
6807+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6808+ offsetof(struct xdp_md, data)),
6809+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6810+ offsetof(struct xdp_md, data_end)),
6811+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6812+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6813+ BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_1, 1),
6814+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6815+ BPF_MOV64_IMM(BPF_REG_0, 0),
6816+ BPF_EXIT_INSN(),
6817+ },
6818+ .errstr = "R1 offset is outside of the packet",
6819+ .result = REJECT,
6820+ .prog_type = BPF_PROG_TYPE_XDP,
6821+ },
6822+ {
6823+ "XDP pkt read, pkt_data' < pkt_end, good access",
6824+ .insns = {
6825+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6826+ offsetof(struct xdp_md, data)),
6827+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6828+ offsetof(struct xdp_md, data_end)),
6829+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6830+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6831+ BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6832+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6833+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6834+ BPF_MOV64_IMM(BPF_REG_0, 0),
6835+ BPF_EXIT_INSN(),
6836+ },
6837+ .result = ACCEPT,
6838+ .prog_type = BPF_PROG_TYPE_XDP,
6839+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6840+ },
6841+ {
6842+ "XDP pkt read, pkt_data' < pkt_end, bad access 1",
6843+ .insns = {
6844+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6845+ offsetof(struct xdp_md, data)),
6846+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6847+ offsetof(struct xdp_md, data_end)),
6848+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6849+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6850+ BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6851+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6852+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6853+ BPF_MOV64_IMM(BPF_REG_0, 0),
6854+ BPF_EXIT_INSN(),
6855+ },
6856+ .errstr = "R1 offset is outside of the packet",
6857+ .result = REJECT,
6858+ .prog_type = BPF_PROG_TYPE_XDP,
6859+ },
6860+ {
6861+ "XDP pkt read, pkt_data' < pkt_end, bad access 2",
6862+ .insns = {
6863+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6864+ offsetof(struct xdp_md, data)),
6865+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6866+ offsetof(struct xdp_md, data_end)),
6867+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6868+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6869+ BPF_JMP_REG(BPF_JLT, BPF_REG_1, BPF_REG_3, 1),
6870+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6871+ BPF_MOV64_IMM(BPF_REG_0, 0),
6872+ BPF_EXIT_INSN(),
6873+ },
6874+ .errstr = "R1 offset is outside of the packet",
6875+ .result = REJECT,
6876+ .prog_type = BPF_PROG_TYPE_XDP,
6877+ },
6878+ {
6879+ "XDP pkt read, pkt_end < pkt_data', good access",
6880+ .insns = {
6881+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6882+ offsetof(struct xdp_md, data)),
6883+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6884+ offsetof(struct xdp_md, data_end)),
6885+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6886+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6887+ BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 1),
6888+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6889+ BPF_MOV64_IMM(BPF_REG_0, 0),
6890+ BPF_EXIT_INSN(),
6891+ },
6892+ .result = ACCEPT,
6893+ .prog_type = BPF_PROG_TYPE_XDP,
6894+ },
6895+ {
6896+ "XDP pkt read, pkt_end < pkt_data', bad access 1",
6897+ .insns = {
6898+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6899+ offsetof(struct xdp_md, data)),
6900+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6901+ offsetof(struct xdp_md, data_end)),
6902+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6903+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6904+ BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 1),
6905+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
6906+ BPF_MOV64_IMM(BPF_REG_0, 0),
6907+ BPF_EXIT_INSN(),
6908+ },
6909+ .errstr = "R1 offset is outside of the packet",
6910+ .result = REJECT,
6911+ .prog_type = BPF_PROG_TYPE_XDP,
6912+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6913+ },
6914+ {
6915+ "XDP pkt read, pkt_end < pkt_data', bad access 2",
6916+ .insns = {
6917+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6918+ offsetof(struct xdp_md, data)),
6919+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6920+ offsetof(struct xdp_md, data_end)),
6921+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6922+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6923+ BPF_JMP_REG(BPF_JLT, BPF_REG_3, BPF_REG_1, 0),
6924+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6925+ BPF_MOV64_IMM(BPF_REG_0, 0),
6926+ BPF_EXIT_INSN(),
6927+ },
6928+ .errstr = "R1 offset is outside of the packet",
6929+ .result = REJECT,
6930+ .prog_type = BPF_PROG_TYPE_XDP,
6931+ },
6932+ {
6933+ "XDP pkt read, pkt_data' >= pkt_end, good access",
6934+ .insns = {
6935+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6936+ offsetof(struct xdp_md, data)),
6937+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6938+ offsetof(struct xdp_md, data_end)),
6939+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6940+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6941+ BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 1),
6942+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6943+ BPF_MOV64_IMM(BPF_REG_0, 0),
6944+ BPF_EXIT_INSN(),
6945+ },
6946+ .result = ACCEPT,
6947+ .prog_type = BPF_PROG_TYPE_XDP,
6948+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6949+ },
6950+ {
6951+ "XDP pkt read, pkt_data' >= pkt_end, bad access 1",
6952+ .insns = {
6953+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6954+ offsetof(struct xdp_md, data)),
6955+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6956+ offsetof(struct xdp_md, data_end)),
6957+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6958+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6959+ BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 1),
6960+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6961+ BPF_MOV64_IMM(BPF_REG_0, 0),
6962+ BPF_EXIT_INSN(),
6963+ },
6964+ .errstr = "R1 offset is outside of the packet",
6965+ .result = REJECT,
6966+ .prog_type = BPF_PROG_TYPE_XDP,
6967+ },
6968+ {
6969+ "XDP pkt read, pkt_data' >= pkt_end, bad access 2",
6970+ .insns = {
6971+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6972+ offsetof(struct xdp_md, data)),
6973+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6974+ offsetof(struct xdp_md, data_end)),
6975+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6976+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6977+ BPF_JMP_REG(BPF_JGE, BPF_REG_1, BPF_REG_3, 0),
6978+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
6979+ BPF_MOV64_IMM(BPF_REG_0, 0),
6980+ BPF_EXIT_INSN(),
6981+ },
6982+ .errstr = "R1 offset is outside of the packet",
6983+ .result = REJECT,
6984+ .prog_type = BPF_PROG_TYPE_XDP,
6985+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
6986+ },
6987+ {
6988+ "XDP pkt read, pkt_end >= pkt_data', good access",
6989+ .insns = {
6990+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
6991+ offsetof(struct xdp_md, data)),
6992+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
6993+ offsetof(struct xdp_md, data_end)),
6994+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
6995+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
6996+ BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
6997+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
6998+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
6999+ BPF_MOV64_IMM(BPF_REG_0, 0),
7000+ BPF_EXIT_INSN(),
7001+ },
7002+ .result = ACCEPT,
7003+ .prog_type = BPF_PROG_TYPE_XDP,
7004+ },
7005+ {
7006+ "XDP pkt read, pkt_end >= pkt_data', bad access 1",
7007+ .insns = {
7008+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7009+ offsetof(struct xdp_md, data)),
7010+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7011+ offsetof(struct xdp_md, data_end)),
7012+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7013+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7014+ BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
7015+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7016+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
7017+ BPF_MOV64_IMM(BPF_REG_0, 0),
7018+ BPF_EXIT_INSN(),
7019+ },
7020+ .errstr = "R1 offset is outside of the packet",
7021+ .result = REJECT,
7022+ .prog_type = BPF_PROG_TYPE_XDP,
7023+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7024+ },
7025+ {
7026+ "XDP pkt read, pkt_end >= pkt_data', bad access 2",
7027+ .insns = {
7028+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7029+ offsetof(struct xdp_md, data)),
7030+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7031+ offsetof(struct xdp_md, data_end)),
7032+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7033+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7034+ BPF_JMP_REG(BPF_JGE, BPF_REG_3, BPF_REG_1, 1),
7035+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7036+ BPF_MOV64_IMM(BPF_REG_0, 0),
7037+ BPF_EXIT_INSN(),
7038+ },
7039+ .errstr = "R1 offset is outside of the packet",
7040+ .result = REJECT,
7041+ .prog_type = BPF_PROG_TYPE_XDP,
7042+ },
7043+ {
7044+ "XDP pkt read, pkt_data' <= pkt_end, good access",
7045+ .insns = {
7046+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7047+ offsetof(struct xdp_md, data)),
7048+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7049+ offsetof(struct xdp_md, data_end)),
7050+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7051+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7052+ BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7053+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7054+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7055+ BPF_MOV64_IMM(BPF_REG_0, 0),
7056+ BPF_EXIT_INSN(),
7057+ },
7058+ .result = ACCEPT,
7059+ .prog_type = BPF_PROG_TYPE_XDP,
7060+ },
7061+ {
7062+ "XDP pkt read, pkt_data' <= pkt_end, bad access 1",
7063+ .insns = {
7064+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7065+ offsetof(struct xdp_md, data)),
7066+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7067+ offsetof(struct xdp_md, data_end)),
7068+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7069+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7070+ BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7071+ BPF_JMP_IMM(BPF_JA, 0, 0, 1),
7072+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -4),
7073+ BPF_MOV64_IMM(BPF_REG_0, 0),
7074+ BPF_EXIT_INSN(),
7075+ },
7076+ .errstr = "R1 offset is outside of the packet",
7077+ .result = REJECT,
7078+ .prog_type = BPF_PROG_TYPE_XDP,
7079+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7080+ },
7081+ {
7082+ "XDP pkt read, pkt_data' <= pkt_end, bad access 2",
7083+ .insns = {
7084+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7085+ offsetof(struct xdp_md, data)),
7086+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7087+ offsetof(struct xdp_md, data_end)),
7088+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7089+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7090+ BPF_JMP_REG(BPF_JLE, BPF_REG_1, BPF_REG_3, 1),
7091+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7092+ BPF_MOV64_IMM(BPF_REG_0, 0),
7093+ BPF_EXIT_INSN(),
7094+ },
7095+ .errstr = "R1 offset is outside of the packet",
7096+ .result = REJECT,
7097+ .prog_type = BPF_PROG_TYPE_XDP,
7098+ },
7099+ {
7100+ "XDP pkt read, pkt_end <= pkt_data', good access",
7101+ .insns = {
7102+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7103+ offsetof(struct xdp_md, data)),
7104+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7105+ offsetof(struct xdp_md, data_end)),
7106+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7107+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7108+ BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 1),
7109+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
7110+ BPF_MOV64_IMM(BPF_REG_0, 0),
7111+ BPF_EXIT_INSN(),
7112+ },
7113+ .result = ACCEPT,
7114+ .prog_type = BPF_PROG_TYPE_XDP,
7115+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7116+ },
7117+ {
7118+ "XDP pkt read, pkt_end <= pkt_data', bad access 1",
7119+ .insns = {
7120+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7121+ offsetof(struct xdp_md, data)),
7122+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7123+ offsetof(struct xdp_md, data_end)),
7124+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7125+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7126+ BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 1),
7127+ BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, -8),
7128+ BPF_MOV64_IMM(BPF_REG_0, 0),
7129+ BPF_EXIT_INSN(),
7130+ },
7131+ .errstr = "R1 offset is outside of the packet",
7132+ .result = REJECT,
7133+ .prog_type = BPF_PROG_TYPE_XDP,
7134+ },
7135+ {
7136+ "XDP pkt read, pkt_end <= pkt_data', bad access 2",
7137+ .insns = {
7138+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1,
7139+ offsetof(struct xdp_md, data)),
7140+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1,
7141+ offsetof(struct xdp_md, data_end)),
7142+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_2),
7143+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
7144+ BPF_JMP_REG(BPF_JLE, BPF_REG_3, BPF_REG_1, 0),
7145+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, -5),
7146+ BPF_MOV64_IMM(BPF_REG_0, 0),
7147+ BPF_EXIT_INSN(),
7148+ },
7149+ .errstr = "R1 offset is outside of the packet",
7150+ .result = REJECT,
7151+ .prog_type = BPF_PROG_TYPE_XDP,
7152+ .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
7153+ },
66487154 };
66497155
66507156 static int probe_filter_length(const struct bpf_insn *fp)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t