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
182/* FLEXCAN hardware feature flags182/* FLEXCAN hardware feature flags
183 *183 *
184 * Below is some version info we got:184 * Below is some version info we got:
185 * SOC Version IP-Version Glitch- [TR]WRN_INT Memory err RTR re-185 * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re-
186 * Filter? connected? detection ception in MB186 * Filter? connected? Passive detection ception in MB
187 * MX25 FlexCAN2 03.00.00.00 no no no no187 * MX25 FlexCAN2 03.00.00.00 no no ? no no
188 * MX28 FlexCAN2 03.00.04.00 yes yes no no188 * MX28 FlexCAN2 03.00.04.00 yes yes no no no
189 * MX35 FlexCAN2 03.00.00.00 no no no no189 * MX35 FlexCAN2 03.00.00.00 no no ? no no
190 * MX53 FlexCAN2 03.00.00.00 yes no no no190 * MX53 FlexCAN2 03.00.00.00 yes no no no no
191 * MX6s FlexCAN3 10.00.12.00 yes yes no yes191 * MX6s FlexCAN3 10.00.12.00 yes yes no no yes
192 * VF610 FlexCAN3 ? no yes yes yes?192 * VF610 FlexCAN3 ? no yes ? yes yes?
193 *193 *
194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
195 */195 */
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 */
197#define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */197#define FLEXCAN_QUIRK_DISABLE_RXFG BIT(2) /* Disable RX FIFO Global mask */
198#define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */198#define FLEXCAN_QUIRK_ENABLE_EACEN_RRS BIT(3) /* Enable EACEN and RRS bit in ctrl2 */
199#define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */199#define FLEXCAN_QUIRK_DISABLE_MECR BIT(4) /* Disable Memory error detection */
200#define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based offloading */200#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 */
201 202
202/* Structure of the message buffer */203/* Structure of the message buffer */
203struct flexcan_mb {204struct flexcan_mb {
@@ -281,14 +282,17 @@ struct flexcan_priv { · 77 unmodified lines
281};282};
282 283
283static const struct flexcan_devtype_data fsl_p1010_devtype_data = {284static 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,
285};287};
286 288
287static const struct flexcan_devtype_data fsl_imx28_devtype_data;289static const struct flexcan_devtype_data fsl_imx28_devtype_data = {
290 .quirks = FLEXCAN_QUIRK_BROKEN_PERR_STATE,
291};
288 292
289static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {293static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {
290 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |294 .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,
292};296};
293 297
294static const struct flexcan_devtype_data fsl_vf610_devtype_data = {298static 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
335}339}
336#endif340#endif
337 341
342static 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
350static 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
338static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)358static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
339{359{
340 if (!priv->reg_xceiver)360 if (!priv->reg_xceiver)
@@ -713,6 +733,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) · 372 unmodified lines
713 struct flexcan_regs __iomem *regs = priv->regs;733 struct flexcan_regs __iomem *regs = priv->regs;
714 irqreturn_t handled = IRQ_NONE;734 irqreturn_t handled = IRQ_NONE;
715 u32 reg_iflag1, reg_esr;735 u32 reg_iflag1, reg_esr;
736 enum can_state last_state = priv->can.state;
716 737
717 reg_iflag1 = flexcan_read(&regs->iflag1);738 reg_iflag1 = flexcan_read(&regs->iflag1);
718 739
@@ -765,8 +786,10 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) · 46 unmodified lines
765 flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);786 flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);
766 }787 }
767 788
768 /* state change interrupt */789 /* state change interrupt or broken error state quirk fix is enabled */
769 if (reg_esr & FLEXCAN_ESR_ERR_STATE)790 if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
791 (priv->devtype_data->quirks & (FLEXCAN_QUIRK_BROKEN_WERR_STATE |
792 FLEXCAN_QUIRK_BROKEN_PERR_STATE)))
770 flexcan_irq_state(dev, reg_esr);793 flexcan_irq_state(dev, reg_esr);
771 794
772 /* bus error IRQ - handle if bus error reporting is activated */795 /* 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
774 (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))797 (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
775 flexcan_irq_bus_err(dev, reg_esr);798 flexcan_irq_bus_err(dev, reg_esr);
776 799
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
777 return handled;838 return handled;
778}839}
779 840
@@ -887,7 +948,7 @@ static int flexcan_chip_start(struct net_device *dev) · 107 unmodified lines
887 * on most Flexcan cores, too. Otherwise we don't get948 * on most Flexcan cores, too. Otherwise we don't get
888 * any error warning or passive interrupts.949 * any error warning or passive interrupts.
889 */950 */
890 if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_ERR_STATE ||951 if (priv->devtype_data->quirks & FLEXCAN_QUIRK_BROKEN_WERR_STATE ||
891 priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)952 priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
892 reg_ctrl |= FLEXCAN_CTRL_ERR_MSK;953 reg_ctrl |= FLEXCAN_CTRL_ERR_MSK;
893 else954 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
333 }333 }
334 334
335 cf->can_id = id & ESD_IDMASK;335 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);
337 337
338 if (id & ESD_EXTID)338 if (id & ESD_EXTID)
339 cf->can_id |= CAN_EFF_FLAG;339 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
375 375
376 gs_free_tx_context(txc);376 gs_free_tx_context(txc);
377 377
378 atomic_dec(&dev->active_tx_urbs);
379
378 netif_wake_queue(netdev);380 netif_wake_queue(netdev);
379 }381 }
380 382
@@ -463,14 +465,6 @@ static void gs_usb_xmit_callback(struct urb *urb) · 82 unmodified lines
463 urb->transfer_buffer_length,465 urb->transfer_buffer_length,
464 urb->transfer_buffer,466 urb->transfer_buffer,
465 urb->transfer_dma);467 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);
474}468}
475 469
476static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,470static 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
214 214
215static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr)215static int mv88e6060_set_addr(struct dsa_switch *ds, u8 *addr)
216{216{
217 /* Use the same MAC Address as FD Pause frames for all ports */217 u16 val = addr[0] << 8 | addr[1];
218 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_01, (addr[0] << 9) | 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);
219 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_23, (addr[2] << 8) | addr[3]);225 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_23, (addr[2] << 8) | addr[3]);
220 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_45, (addr[4] << 8) | addr[5]);226 REG_WRITE(REG_GLOBAL, GLOBAL_MAC_45, (addr[4] << 8) | addr[5]);
221 227
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
742{742{
743 struct ena_adapter *adapter = netdev_priv(netdev);743 struct ena_adapter *adapter = netdev_priv(netdev);
744 744
745 channels->max_rx = ENA_MAX_NUM_IO_QUEUES;745 channels->max_rx = adapter->num_queues;
746 channels->max_tx = ENA_MAX_NUM_IO_QUEUES;746 channels->max_tx = adapter->num_queues;
747 channels->max_other = 0;747 channels->max_other = 0;
748 channels->max_combined = 0;748 channels->max_combined = 0;
749 channels->rx_count = adapter->num_queues;749 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
966 u64_stats_update_begin(&rx_ring->syncp);966 u64_stats_update_begin(&rx_ring->syncp);
967 rx_ring->rx_stats.bad_csum++;967 rx_ring->rx_stats.bad_csum++;
968 u64_stats_update_end(&rx_ring->syncp);968 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,
970 "RX IPv4 header checksum error\n");970 "RX IPv4 header checksum error\n");
971 return;971 return;
972 }972 }
@@ -979,7 +979,7 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring, · 6 unmodified lines
979 u64_stats_update_begin(&rx_ring->syncp);979 u64_stats_update_begin(&rx_ring->syncp);
980 rx_ring->rx_stats.bad_csum++;980 rx_ring->rx_stats.bad_csum++;
981 u64_stats_update_end(&rx_ring->syncp);981 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,
983 "RX L4 checksum error\n");983 "RX L4 checksum error\n");
984 skb->ip_summed = CHECKSUM_NONE;984 skb->ip_summed = CHECKSUM_NONE;
985 return;985 return;
@@ -3064,7 +3064,8 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev) · 2078 unmodified lines
3064 if (ena_dev->mem_bar)3064 if (ena_dev->mem_bar)
3065 devm_iounmap(&pdev->dev, ena_dev->mem_bar);3065 devm_iounmap(&pdev->dev, ena_dev->mem_bar);
3066 3066
3067 devm_iounmap(&pdev->dev, ena_dev->reg_bar);3067 if (ena_dev->reg_bar)
3068 devm_iounmap(&pdev->dev, ena_dev->reg_bar);
3068 3069
3069 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;3070 release_bars = pci_select_bars(pdev, IORESOURCE_MEM) & ENA_BAR_MASK;
3070 pci_release_selected_regions(pdev, release_bars);3071 pci_release_selected_regions(pdev, release_bars);
drivers/net/ethernet/aquantia/atlantic/aq_cfg.h+6−2
@@ -22,8 +22,12 @@ · 21 unmodified lines
22 22
23#define AQ_CFG_FORCE_LEGACY_INT 0U23#define AQ_CFG_FORCE_LEGACY_INT 0U
24 24
25#define AQ_CFG_IS_INTERRUPT_MODERATION_DEF 1U25#define AQ_CFG_INTERRUPT_MODERATION_OFF 0
26#define AQ_CFG_INTERRUPT_MODERATION_RATE_DEF 0xFFFFU26#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
27#define AQ_CFG_IRQ_MASK 0x1FFU31#define AQ_CFG_IRQ_MASK 0x1FFU
28 32
29#define AQ_CFG_VECS_MAX 8U33#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
56 return aq_nic_set_link_ksettings(aq_nic, cmd);56 return aq_nic_set_link_ksettings(aq_nic, cmd);
57}57}
58 58
59/* there "5U" is number of queue[#] stats lines (InPackets+...+InErrors) */
60static const unsigned int aq_ethtool_stat_queue_lines = 5U;
61static const unsigned int aq_ethtool_stat_queue_chars =
62 5U * ETH_GSTRING_LEN;
63static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {59static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
64 "InPackets",60 "InPackets",
65 "InUCast",61 "InUCast",
@@ -83,56 +79,26 @@ static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = { · 17 unmodified lines
83 "InOctetsDma",79 "InOctetsDma",
84 "OutOctetsDma",80 "OutOctetsDma",
85 "InDroppedDma",81 "InDroppedDma",
86 "Queue[0] InPackets",82};
87 "Queue[0] OutPackets",83
88 "Queue[0] InJumboPackets",84static const char aq_ethtool_queue_stat_names[][ETH_GSTRING_LEN] = {
89 "Queue[0] InLroPackets",85 "Queue[%d] InPackets",
90 "Queue[0] InErrors",86 "Queue[%d] OutPackets",
91 "Queue[1] InPackets",87 "Queue[%d] Restarts",
92 "Queue[1] OutPackets",88 "Queue[%d] InJumboPackets",
93 "Queue[1] InJumboPackets",89 "Queue[%d] InLroPackets",
94 "Queue[1] InLroPackets",90 "Queue[%d] InErrors",
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",
126};91};
127 92
128static void aq_ethtool_stats(struct net_device *ndev,93static void aq_ethtool_stats(struct net_device *ndev,
129 struct ethtool_stats *stats, u64 *data)94 struct ethtool_stats *stats, u64 *data)
130{95{
131 struct aq_nic_s *aq_nic = netdev_priv(ndev);96 struct aq_nic_s *aq_nic = netdev_priv(ndev);
97 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
132 98
133/* ASSERT: Need add lines to aq_ethtool_stat_names if AQ_CFG_VECS_MAX > 8 */99 memset(data, 0, (ARRAY_SIZE(aq_ethtool_stat_names) +
134 BUILD_BUG_ON(AQ_CFG_VECS_MAX > 8);100 ARRAY_SIZE(aq_ethtool_queue_stat_names) *
135 memset(data, 0, ARRAY_SIZE(aq_ethtool_stat_names) * sizeof(u64));101 cfg->vecs) * sizeof(u64));
136 aq_nic_get_stats(aq_nic, data);102 aq_nic_get_stats(aq_nic, data);
137}103}
138 104
@@ -154,8 +120,8 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev, · 15 unmodified lines
154 120
155 strlcpy(drvinfo->bus_info, pdev ? pci_name(pdev) : "",121 strlcpy(drvinfo->bus_info, pdev ? pci_name(pdev) : "",
156 sizeof(drvinfo->bus_info));122 sizeof(drvinfo->bus_info));
157 drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) -123 drvinfo->n_stats = ARRAY_SIZE(aq_ethtool_stat_names) +
158 (AQ_CFG_VECS_MAX - cfg->vecs) * aq_ethtool_stat_queue_lines;124 cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
159 drvinfo->testinfo_len = 0;125 drvinfo->testinfo_len = 0;
160 drvinfo->regdump_len = regs_count;126 drvinfo->regdump_len = regs_count;
161 drvinfo->eedump_len = 0;127 drvinfo->eedump_len = 0;
@@ -164,14 +130,25 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev, · 2 unmodified lines
164static void aq_ethtool_get_strings(struct net_device *ndev,130static void aq_ethtool_get_strings(struct net_device *ndev,
165 u32 stringset, u8 *data)131 u32 stringset, u8 *data)
166{132{
133 int i, si;
167 struct aq_nic_s *aq_nic = netdev_priv(ndev);134 struct aq_nic_s *aq_nic = netdev_priv(ndev);
168 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);135 struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
169 136 u8 *p = data;
170 if (stringset == ETH_SS_STATS)137
171 memcpy(data, *aq_ethtool_stat_names,138 if (stringset == ETH_SS_STATS) {
172 sizeof(aq_ethtool_stat_names) -139 memcpy(p, *aq_ethtool_stat_names,
173 (AQ_CFG_VECS_MAX - cfg->vecs) *140 sizeof(aq_ethtool_stat_names));
174 aq_ethtool_stat_queue_chars);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 }
175}152}
176 153
177static int aq_ethtool_get_sset_count(struct net_device *ndev, int stringset)154static 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
182 159
183 switch (stringset) {160 switch (stringset) {
184 case ETH_SS_STATS:161 case ETH_SS_STATS:
185 ret = ARRAY_SIZE(aq_ethtool_stat_names) -162 ret = ARRAY_SIZE(aq_ethtool_stat_names) +
186 (AQ_CFG_VECS_MAX - cfg->vecs) *163 cfg->vecs * ARRAY_SIZE(aq_ethtool_queue_stat_names);
187 aq_ethtool_stat_queue_lines;
188 break;164 break;
189 default:165 default:
190 ret = -EOPNOTSUPP;166 ret = -EOPNOTSUPP;
@@ -245,6 +221,69 @@ static int aq_ethtool_get_rxnfc(struct net_device *ndev, · 54 unmodified lines
245 return err;221 return err;
246}222}
247 223
224int 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
245int 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
248const struct ethtool_ops aq_ethtool_ops = {287const struct ethtool_ops aq_ethtool_ops = {
249 .get_link = aq_ethtool_get_link,288 .get_link = aq_ethtool_get_link,
250 .get_regs_len = aq_ethtool_get_regs_len,289 .get_regs_len = aq_ethtool_get_regs_len,
@@ -259,4 +298,6 @@ const struct ethtool_ops aq_ethtool_ops = { · 8 unmodified lines
259 .get_ethtool_stats = aq_ethtool_stats,298 .get_ethtool_stats = aq_ethtool_stats,
260 .get_link_ksettings = aq_ethtool_get_link_ksettings,299 .get_link_ksettings = aq_ethtool_get_link_ksettings,
261 .set_link_ksettings = aq_ethtool_set_link_ksettings,300 .set_link_ksettings = aq_ethtool_set_link_ksettings,
301 .get_coalesce = aq_ethtool_get_coalesce,
302 .set_coalesce = aq_ethtool_set_coalesce,
262};303};
drivers/net/ethernet/aquantia/atlantic/aq_hw.h+3−2
@@ -151,8 +151,7 @@ struct aq_hw_ops { · 150 unmodified lines
151 [ETH_ALEN],151 [ETH_ALEN],
152 u32 count);152 u32 count);
153 153
154 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self,154 int (*hw_interrupt_moderation_set)(struct aq_hw_s *self);
155 bool itr_enabled);
156 155
157 int (*hw_rss_set)(struct aq_hw_s *self,156 int (*hw_rss_set)(struct aq_hw_s *self,
158 struct aq_rss_parameters *rss_params);157 struct aq_rss_parameters *rss_params);
@@ -163,6 +162,8 @@ struct aq_hw_ops { · 4 unmodified lines
163 int (*hw_get_regs)(struct aq_hw_s *self,162 int (*hw_get_regs)(struct aq_hw_s *self,
164 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);163 struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);
165 164
165 int (*hw_update_stats)(struct aq_hw_s *self);
166
166 int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,167 int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,
167 unsigned int *p_count);168 unsigned int *p_count);
168 169
drivers/net/ethernet/aquantia/atlantic/aq_nic.c+30−9
@@ -16,6 +16,7 @@ · 15 unmodified lines
16#include "aq_pci_func.h"16#include "aq_pci_func.h"
17#include "aq_nic_internal.h"17#include "aq_nic_internal.h"
18 18
19#include <linux/moduleparam.h>
19#include <linux/netdevice.h>20#include <linux/netdevice.h>
20#include <linux/etherdevice.h>21#include <linux/etherdevice.h>
21#include <linux/timer.h>22#include <linux/timer.h>
@@ -24,6 +25,18 @@ · 2 unmodified lines
24#include <linux/tcp.h>25#include <linux/tcp.h>
25#include <net/ip.h>26#include <net/ip.h>
26 27
28static unsigned int aq_itr = AQ_CFG_INTERRUPT_MODERATION_AUTO;
29module_param_named(aq_itr, aq_itr, uint, 0644);
30MODULE_PARM_DESC(aq_itr, "Interrupt throttling mode");
31
32static unsigned int aq_itr_tx;
33module_param_named(aq_itr_tx, aq_itr_tx, uint, 0644);
34MODULE_PARM_DESC(aq_itr_tx, "TX interrupt throttle rate");
35
36static unsigned int aq_itr_rx;
37module_param_named(aq_itr_rx, aq_itr_rx, uint, 0644);
38MODULE_PARM_DESC(aq_itr_rx, "RX interrupt throttle rate");
39
27static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues)40static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues)
28{41{
29 struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;42 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
61 74
62 cfg->is_polling = AQ_CFG_IS_POLLING_DEF;75 cfg->is_polling = AQ_CFG_IS_POLLING_DEF;
63 76
64 cfg->is_interrupt_moderation = AQ_CFG_IS_INTERRUPT_MODERATION_DEF;77 cfg->itr = aq_itr;
65 cfg->itr = cfg->is_interrupt_moderation ?78 cfg->tx_itr = aq_itr_tx;
66 AQ_CFG_INTERRUPT_MODERATION_RATE_DEF : 0U;79 cfg->rx_itr = aq_itr_rx;
67 80
68 cfg->is_rss = AQ_CFG_IS_RSS_DEF;81 cfg->is_rss = AQ_CFG_IS_RSS_DEF;
69 cfg->num_rss_queues = AQ_CFG_NUM_RSS_QUEUES_DEF;82 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
126 if (err)139 if (err)
127 return err;140 return err;
128 141
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) {
130 pr_info("%s: link change old %d new %d\n",143 pr_info("%s: link change old %d new %d\n",
131 AQ_CFG_DRV_NAME, self->link_status.mbps,144 AQ_CFG_DRV_NAME, self->link_status.mbps,
132 self->aq_hw->aq_link_status.mbps);145 self->aq_hw->aq_link_status.mbps);
146 aq_nic_update_interrupt_moderation_settings(self);
147 }
133 148
134 self->link_status = self->aq_hw->aq_link_status;149 self->link_status = self->aq_hw->aq_link_status;
135 if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) {150 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
164 if (err)179 if (err)
165 goto err_exit;180 goto err_exit;
166 181
167 self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,182 if (self->aq_hw_ops.hw_update_stats)
168 self->aq_nic_cfg.is_interrupt_moderation);183 self->aq_hw_ops.hw_update_stats(self->aq_hw);
169 184
170 memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));185 memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));
171 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));186 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
334 }349 }
335 if (netif_running(ndev))350 if (netif_running(ndev))
336 netif_tx_disable(ndev);351 netif_tx_disable(ndev);
352 netif_carrier_off(self->ndev);
337 353
338 for (self->aq_vecs = 0; self->aq_vecs < self->aq_nic_cfg.vecs;354 for (self->aq_vecs = 0; self->aq_vecs < self->aq_nic_cfg.vecs;
339 self->aq_vecs++) {355 self->aq_vecs++) {
@@ -421,9 +437,8 @@ int aq_nic_start(struct aq_nic_s *self) · 81 unmodified lines
421 if (err < 0)437 if (err < 0)
422 goto err_exit;438 goto err_exit;
423 439
424 err = self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,440 err = aq_nic_update_interrupt_moderation_settings(self);
425 self->aq_nic_cfg.is_interrupt_moderation);441 if (err)
426 if (err < 0)
427 goto err_exit;442 goto err_exit;
428 setup_timer(&self->service_timer, &aq_nic_service_timer_cb,443 setup_timer(&self->service_timer, &aq_nic_service_timer_cb,
429 (unsigned long)self);444 (unsigned long)self);
@@ -645,6 +660,11 @@ err_exit: · 215 unmodified lines
645 return err;660 return err;
646}661}
647 662
663int 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
648int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags)668int aq_nic_set_packet_filter(struct aq_nic_s *self, unsigned int flags)
649{669{
650 int err = 0;670 int err = 0;
@@ -899,6 +919,7 @@ int aq_nic_stop(struct aq_nic_s *self) · 248 unmodified lines
899 unsigned int i = 0U;919 unsigned int i = 0U;
900 920
901 netif_tx_disable(self->ndev);921 netif_tx_disable(self->ndev);
922 netif_carrier_off(self->ndev);
902 923
903 del_timer_sync(&self->service_timer);924 del_timer_sync(&self->service_timer);
904 925
drivers/net/ethernet/aquantia/atlantic/aq_nic.h+3−1
@@ -40,6 +40,8 @@ struct aq_nic_cfg_s { · 39 unmodified lines
40 u32 vecs; /* vecs==allocated irqs */40 u32 vecs; /* vecs==allocated irqs */
41 u32 irq_type;41 u32 irq_type;
42 u32 itr;42 u32 itr;
43 u16 rx_itr;
44 u16 tx_itr;
43 u32 num_rss_queues;45 u32 num_rss_queues;
44 u32 mtu;46 u32 mtu;
45 u32 ucp_0x364;47 u32 ucp_0x364;
@@ -49,7 +51,6 @@ struct aq_nic_cfg_s { · 3 unmodified lines
49 u16 is_mc_list_enabled;51 u16 is_mc_list_enabled;
50 u16 mc_list_count;52 u16 mc_list_count;
51 bool is_autoneg;53 bool is_autoneg;
52 bool is_interrupt_moderation;
53 bool is_polling;54 bool is_polling;
54 bool is_rss;55 bool is_rss;
55 bool is_lro;56 bool is_lro;
@@ -104,5 +105,6 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self, · 48 unmodified lines
104struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);105struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
105u32 aq_nic_get_fw_version(struct aq_nic_s *self);106u32 aq_nic_get_fw_version(struct aq_nic_s *self);
106int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);107int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg);
108int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
107 109
108#endif /* AQ_NIC_H */110#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
85 int err = 0;85 int err = 0;
86 unsigned int bar = 0U;86 unsigned int bar = 0U;
87 unsigned int port = 0U;87 unsigned int port = 0U;
88 unsigned int numvecs = 0U;
88 89
89 err = pci_enable_device(self->pdev);90 err = pci_enable_device(self->pdev);
90 if (err < 0)91 if (err < 0)
@@ -142,10 +143,12 @@ int aq_pci_func_init(struct aq_pci_func_s *self) · 51 unmodified lines
142 }143 }
143 }144 }
144 145
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 */
146#if !AQ_CFG_FORCE_LEGACY_INT150#if !AQ_CFG_FORCE_LEGACY_INT
147 err = pci_alloc_irq_vectors(self->pdev, self->aq_hw_caps.msix_irqs,151 err = pci_alloc_irq_vectors(self->pdev, numvecs, numvecs, PCI_IRQ_MSIX);
148 self->aq_hw_caps.msix_irqs, PCI_IRQ_MSIX);
149 152
150 if (err < 0) {153 if (err < 0) {
151 err = pci_alloc_irq_vectors(self->pdev, 1, 1,154 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
153 if (err < 0)156 if (err < 0)
154 goto err_exit;157 goto err_exit;
155 }158 }
156#endif159#endif /* AQ_CFG_FORCE_LEGACY_INT */
157 160
158 /* net device init */161 /* net device init */
159 for (port = 0; port < self->ports; ++port) {162 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
265 aq_nic_ndev_free(self->port[port]);268 aq_nic_ndev_free(self->port[port]);
266 }269 }
267 270
271 if (self->mmio)
272 iounmap(self->mmio);
273
268 kfree(self);274 kfree(self);
269 275
270err_exit:;276err_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
373 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));373 memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
374 aq_vec_add_stats(self, &stats_rx, &stats_tx);374 aq_vec_add_stats(self, &stats_rx, &stats_tx);
375 375
376 /* This data should mimic aq_ethtool_queue_stat_names structure
377 */
376 data[count] += stats_rx.packets;378 data[count] += stats_rx.packets;
377 data[++count] += stats_tx.packets;379 data[++count] += stats_tx.packets;
380 data[++count] += stats_tx.queue_restarts;
378 data[++count] += stats_rx.jumbo_packets;381 data[++count] += stats_rx.jumbo_packets;
379 data[++count] += stats_rx.lro_packets;382 data[++count] += stats_rx.lro_packets;
380 data[++count] += stats_rx.errors;383 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
765 return err;765 return err;
766}766}
767 767
768static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self,768static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self)
769 bool itr_enabled)
770{769{
771 unsigned int i = 0U;770 unsigned int i = 0U;
771 u32 itr_rx;
772 772
773 if (itr_enabled && self->aq_nic_cfg->itr) {773 if (self->aq_nic_cfg->itr) {
774 if (self->aq_nic_cfg->itr != 0xFFFFU) {774 if (self->aq_nic_cfg->itr != AQ_CFG_INTERRUPT_MODERATION_AUTO) {
775 u32 itr_ = (self->aq_nic_cfg->itr >> 1);775 u32 itr_ = (self->aq_nic_cfg->itr >> 1);
776 776
777 itr_ = min(AQ_CFG_IRQ_MASK, itr_);777 itr_ = min(AQ_CFG_IRQ_MASK, itr_);
778 778
779 PHAL_ATLANTIC_A0->itr_rx = 0x80000000U |779 itr_rx = 0x80000000U | (itr_ << 0x10);
780 (itr_ << 0x10);
781 } else {780 } else {
782 u32 n = 0xFFFFU & aq_hw_read_reg(self, 0x00002A00U);781 u32 n = 0xFFFFU & aq_hw_read_reg(self, 0x00002A00U);
783 782
784 if (n < self->aq_link_status.mbps) {783 if (n < self->aq_link_status.mbps) {
785 PHAL_ATLANTIC_A0->itr_rx = 0U;784 itr_rx = 0U;
786 } else {785 } else {
787 static unsigned int hw_timers_tbl_[] = {786 static unsigned int hw_timers_tbl_[] = {
788 0x01CU, /* 10Gbit */787 0x01CU, /* 10Gbit */
@@ -797,8 +796,7 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self, · 8 unmodified lines
797 hw_atl_utils_mbps_2_speed_index(796 hw_atl_utils_mbps_2_speed_index(
798 self->aq_link_status.mbps);797 self->aq_link_status.mbps);
799 798
800 PHAL_ATLANTIC_A0->itr_rx =799 itr_rx = 0x80000000U |
801 0x80000000U |
802 (hw_timers_tbl_[speed_index] << 0x10U);800 (hw_timers_tbl_[speed_index] << 0x10U);
803 }801 }
804 802
@@ -806,11 +804,11 @@ static int hw_atl_a0_hw_interrupt_moderation_set(struct aq_hw_s *self, · 1 unmodified line
806 aq_hw_write_reg(self, 0x00002A00U, 0x8D000000U);804 aq_hw_write_reg(self, 0x00002A00U, 0x8D000000U);
807 }805 }
808 } else {806 } else {
809 PHAL_ATLANTIC_A0->itr_rx = 0U;807 itr_rx = 0U;
810 }808 }
811 809
812 for (i = HW_ATL_A0_RINGS_MAX; i--;)810 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);
814 812
815 return aq_hw_err_from_flags(self);813 return aq_hw_err_from_flags(self);
816}814}
@@ -885,6 +883,7 @@ static struct aq_hw_ops hw_atl_ops_ = { · 68 unmodified lines
885 .hw_rss_set = hw_atl_a0_hw_rss_set,883 .hw_rss_set = hw_atl_a0_hw_rss_set,
886 .hw_rss_hash_set = hw_atl_a0_hw_rss_hash_set,884 .hw_rss_hash_set = hw_atl_a0_hw_rss_hash_set,
887 .hw_get_regs = hw_atl_utils_hw_get_regs,885 .hw_get_regs = hw_atl_utils_hw_get_regs,
886 .hw_update_stats = hw_atl_utils_update_stats,
888 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,887 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
889 .hw_get_fw_version = hw_atl_utils_get_fw_version,888 .hw_get_fw_version = hw_atl_utils_get_fw_version,
890};889};
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c+49−40
@@ -788,39 +788,45 @@ err_exit: · 787 unmodified lines
788 return err;788 return err;
789}789}
790 790
791static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self,791static int hw_atl_b0_hw_interrupt_moderation_set(struct aq_hw_s *self)
792 bool itr_enabled)
793{792{
794 unsigned int i = 0U;793 unsigned int i = 0U;
794 u32 itr_tx = 2U;
795 u32 itr_rx = 2U;
795 796
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:
797 tdm_tx_desc_wr_wb_irq_en_set(self, 0U);800 tdm_tx_desc_wr_wb_irq_en_set(self, 0U);
798 tdm_tdm_intr_moder_en_set(self, 1U);801 tdm_tdm_intr_moder_en_set(self, 1U);
799 rdm_rx_desc_wr_wb_irq_en_set(self, 0U);802 rdm_rx_desc_wr_wb_irq_en_set(self, 0U);
800 rdm_rdm_intr_moder_en_set(self, 1U);803 rdm_rdm_intr_moder_en_set(self, 1U);
801 804
802 PHAL_ATLANTIC_B0->itr_tx = 2U;805 if (self->aq_nic_cfg->itr == AQ_CFG_INTERRUPT_MODERATION_ON) {
803 PHAL_ATLANTIC_B0->itr_rx = 2U;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;
804 809
805 if (self->aq_nic_cfg->itr != 0xFFFFU) {810 int rx_max_timer = self->aq_nic_cfg->rx_itr / 2;
806 unsigned int max_timer = self->aq_nic_cfg->itr / 2U;811 int rx_min_timer = rx_max_timer / 2;
807 unsigned int min_timer = self->aq_nic_cfg->itr / 32U;
808 812
809 max_timer = min(0x1FFU, max_timer);813 tx_max_timer = min(HW_ATL_INTR_MODER_MAX, tx_max_timer);
810 min_timer = min(0xFFU, min_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);
811 817
812 PHAL_ATLANTIC_B0->itr_tx |= min_timer << 0x8U;818 itr_tx |= tx_min_timer << 0x8U;
813 PHAL_ATLANTIC_B0->itr_tx |= max_timer << 0x10U;819 itr_tx |= tx_max_timer << 0x10U;
814 PHAL_ATLANTIC_B0->itr_rx |= min_timer << 0x8U;820 itr_rx |= rx_min_timer << 0x8U;
815 PHAL_ATLANTIC_B0->itr_rx |= max_timer << 0x10U;821 itr_rx |= rx_max_timer << 0x10U;
816 } else {822 } else {
817 static unsigned int hw_atl_b0_timers_table_tx_[][2] = {823 static unsigned int hw_atl_b0_timers_table_tx_[][2] = {
818 {0xffU, 0xffU}, /* 10Gbit */824 {0xfU, 0xffU}, /* 10Gbit */
819 {0xffU, 0x1ffU}, /* 5Gbit */825 {0xfU, 0x1ffU}, /* 5Gbit */
820 {0xffU, 0x1ffU}, /* 5Gbit 5GS */826 {0xfU, 0x1ffU}, /* 5Gbit 5GS */
821 {0xffU, 0x1ffU}, /* 2.5Gbit */827 {0xfU, 0x1ffU}, /* 2.5Gbit */
822 {0xffU, 0x1ffU}, /* 1Gbit */828 {0xfU, 0x1ffU}, /* 1Gbit */
823 {0xffU, 0x1ffU}, /* 100Mbit */829 {0xfU, 0x1ffU}, /* 100Mbit */
824 };830 };
825 831
826 static unsigned int hw_atl_b0_timers_table_rx_[][2] = {832 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
836 hw_atl_utils_mbps_2_speed_index(842 hw_atl_utils_mbps_2_speed_index(
837 self->aq_link_status.mbps);843 self->aq_link_status.mbps);
838 844
839 PHAL_ATLANTIC_B0->itr_tx |=845 /* Update user visible ITR settings */
840 hw_atl_b0_timers_table_tx_[speed_index]846 self->aq_nic_cfg->tx_itr = hw_atl_b0_timers_table_tx_
841 [0] << 0x8U; /* set min timer value */847 [speed_index][1] * 2;
842 PHAL_ATLANTIC_B0->itr_tx |=848 self->aq_nic_cfg->rx_itr = hw_atl_b0_timers_table_rx_
843 hw_atl_b0_timers_table_tx_[speed_index]849 [speed_index][1] * 2;
844 [1] << 0x10U; /* set max timer value */850
845 851 itr_tx |= hw_atl_b0_timers_table_tx_
846 PHAL_ATLANTIC_B0->itr_rx |=852 [speed_index][0] << 0x8U;
847 hw_atl_b0_timers_table_rx_[speed_index]853 itr_tx |= hw_atl_b0_timers_table_tx_
848 [0] << 0x8U; /* set min timer value */854 [speed_index][1] << 0x10U;
849 PHAL_ATLANTIC_B0->itr_rx |=855
850 hw_atl_b0_timers_table_rx_[speed_index]856 itr_rx |= hw_atl_b0_timers_table_rx_
851 [1] << 0x10U; /* set max timer value */857 [speed_index][0] << 0x8U;
858 itr_rx |= hw_atl_b0_timers_table_rx_
859 [speed_index][1] << 0x10U;
852 }860 }
853 } else {861 break;
862 case AQ_CFG_INTERRUPT_MODERATION_OFF:
854 tdm_tx_desc_wr_wb_irq_en_set(self, 1U);863 tdm_tx_desc_wr_wb_irq_en_set(self, 1U);
855 tdm_tdm_intr_moder_en_set(self, 0U);864 tdm_tdm_intr_moder_en_set(self, 0U);
856 rdm_rx_desc_wr_wb_irq_en_set(self, 1U);865 rdm_rx_desc_wr_wb_irq_en_set(self, 1U);
857 rdm_rdm_intr_moder_en_set(self, 0U);866 rdm_rdm_intr_moder_en_set(self, 0U);
858 PHAL_ATLANTIC_B0->itr_tx = 0U;867 itr_tx = 0U;
859 PHAL_ATLANTIC_B0->itr_rx = 0U;868 itr_rx = 0U;
869 break;
860 }870 }
861 871
862 for (i = HW_ATL_B0_RINGS_MAX; i--;) {872 for (i = HW_ATL_B0_RINGS_MAX; i--;) {
863 reg_tx_intr_moder_ctrl_set(self,873 reg_tx_intr_moder_ctrl_set(self, itr_tx, i);
864 PHAL_ATLANTIC_B0->itr_tx, i);874 reg_rx_intr_moder_ctrl_set(self, itr_rx, i);
865 reg_rx_intr_moder_ctrl_set(self,
866 PHAL_ATLANTIC_B0->itr_rx, i);
867 }875 }
868 876
869 return aq_hw_err_from_flags(self);877 return aq_hw_err_from_flags(self);
@@ -939,6 +947,7 @@ static struct aq_hw_ops hw_atl_ops_ = { · 69 unmodified lines
939 .hw_rss_set = hw_atl_b0_hw_rss_set,947 .hw_rss_set = hw_atl_b0_hw_rss_set,
940 .hw_rss_hash_set = hw_atl_b0_hw_rss_hash_set,948 .hw_rss_hash_set = hw_atl_b0_hw_rss_hash_set,
941 .hw_get_regs = hw_atl_utils_hw_get_regs,949 .hw_get_regs = hw_atl_utils_hw_get_regs,
950 .hw_update_stats = hw_atl_utils_update_stats,
942 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,951 .hw_get_hw_stats = hw_atl_utils_get_hw_stats,
943 .hw_get_fw_version = hw_atl_utils_get_fw_version,952 .hw_get_fw_version = hw_atl_utils_get_fw_version,
944};953};
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h+3−0
@@ -139,6 +139,9 @@ · 138 unmodified lines
139 139
140#define HW_ATL_B0_FW_VER_EXPECTED 0x01050006U140#define HW_ATL_B0_FW_VER_EXPECTED 0x01050006U
141 141
142#define HW_ATL_INTR_MODER_MAX 0x1FF
143#define HW_ATL_INTR_MODER_MIN 0xFF
144
142/* Hardware tx descriptor */145/* Hardware tx descriptor */
143struct __packed hw_atl_txd_s {146struct __packed hw_atl_txd_s {
144 u64 buf_addr;147 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
255 return err;255 return err;
256}256}
257 257
258int 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
258void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,267void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
259 struct hw_aq_atl_utils_mbox *pmbox)268 struct hw_aq_atl_utils_mbox *pmbox)
260{269{
@@ -267,9 +276,6 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, · 6 unmodified lines
267 if (err < 0)276 if (err < 0)
268 goto err_exit;277 goto err_exit;
269 278
270 if (pmbox != &PHAL_ATLANTIC->mbox)
271 memcpy(pmbox, &PHAL_ATLANTIC->mbox, sizeof(*pmbox));
272
273 if (IS_CHIP_FEATURE(REVISION_A0)) {279 if (IS_CHIP_FEATURE(REVISION_A0)) {
274 unsigned int mtu = self->aq_nic_cfg ?280 unsigned int mtu = self->aq_nic_cfg ?
275 self->aq_nic_cfg->mtu : 1514U;281 self->aq_nic_cfg->mtu : 1514U;
@@ -299,17 +305,17 @@ void hw_atl_utils_mpi_set(struct aq_hw_s *self, · 23 unmodified lines
299{305{
300 int err = 0;306 int err = 0;
301 u32 transaction_id = 0;307 u32 transaction_id = 0;
308 struct hw_aq_atl_utils_mbox_header mbox;
302 309
303 if (state == MPI_RESET) {310 if (state == MPI_RESET) {
304 hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox);311 hw_atl_utils_mpi_read_mbox(self, &mbox);
305 312
306 transaction_id = PHAL_ATLANTIC->mbox.transaction_id;313 transaction_id = mbox.transaction_id;
307 314
308 AQ_HW_WAIT_FOR(transaction_id !=315 AQ_HW_WAIT_FOR(transaction_id !=
309 (hw_atl_utils_mpi_read_stats316 (hw_atl_utils_mpi_read_mbox(self, &mbox),
310 (self, &PHAL_ATLANTIC->mbox),317 mbox.transaction_id),
311 PHAL_ATLANTIC->mbox.transaction_id),318 1000U, 100U);
312 1000U, 100U);
313 if (err < 0)319 if (err < 0)
314 goto err_exit;320 goto err_exit;
315 }321 }
@@ -492,16 +498,51 @@ int hw_atl_utils_hw_set_power(struct aq_hw_s *self, · 176 unmodified lines
492 return 0;498 return 0;
493}499}
494 500
501int 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
495int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,539int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
496 u64 *data, unsigned int *p_count)540 u64 *data, unsigned int *p_count)
497{541{
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;
499 int i = 0;544 int i = 0;
500 545
501 hw_atl_utils_mpi_read_stats(self, &PHAL_ATLANTIC->mbox);
502
503 stats = &PHAL_ATLANTIC->mbox.stats;
504
505 data[i] = stats->uprc + stats->mprc + stats->bprc;546 data[i] = stats->uprc + stats->mprc + stats->bprc;
506 data[++i] = stats->uprc;547 data[++i] = stats->uprc;
507 data[++i] = stats->mprc;548 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
115 };115 };
116};116};
117 117
118struct __packed hw_aq_atl_utils_mbox {118struct __packed hw_aq_atl_utils_mbox_header {
119 u32 version;119 u32 version;
120 u32 transaction_id;120 u32 transaction_id;
121 int error;121 u32 error;
122};
123
124struct __packed hw_aq_atl_utils_mbox {
125 struct hw_aq_atl_utils_mbox_header header;
122 struct hw_atl_stats_s stats;126 struct hw_atl_stats_s stats;
123};127};
124 128
125struct __packed hw_atl_s {129struct __packed hw_atl_s {
126 struct aq_hw_s base;130 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;
128 u64 speed;133 u64 speed;
129 u32 itr_tx;
130 u32 itr_rx;
131 unsigned int chip_features;134 unsigned int chip_features;
132 u32 fw_ver_actual;135 u32 fw_ver_actual;
133 atomic_t dpc;136 atomic_t dpc;
@@ -170,6 +173,9 @@ enum hal_atl_utils_fw_state_e { · 36 unmodified lines
170 173
171void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);174void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p);
172 175
176int hw_atl_utils_mpi_read_mbox(struct aq_hw_s *self,
177 struct hw_aq_atl_utils_mbox_header *pmbox);
178
173void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,179void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
174 struct hw_aq_atl_utils_mbox *pmbox);180 struct hw_aq_atl_utils_mbox *pmbox);
175 181
@@ -199,6 +205,8 @@ int hw_atl_utils_hw_deinit(struct aq_hw_s *self); · 23 unmodified lines
199 205
200int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version);206int hw_atl_utils_get_fw_version(struct aq_hw_s *self, u32 *fw_version);
201 207
208int hw_atl_utils_update_stats(struct aq_hw_s *self);
209
202int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,210int hw_atl_utils_get_hw_stats(struct aq_hw_s *self,
203 u64 *data,211 u64 *data,
204 unsigned int *p_count);212 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
214 ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,214 ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE,
215};215};
216 216
217static struct workqueue_struct *bnxt_pf_wq;
218
217static bool bnxt_vf_pciid(enum board_idx idx)219static bool bnxt_vf_pciid(enum board_idx idx)
218{220{
219 return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF);221 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
1024 return 0;1026 return 0;
1025}1027}
1026 1028
1029static 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
1037static 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
1027static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)1045static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
1028{1046{
1029 if (!rxr->bnapi->in_reset) {1047 if (!rxr->bnapi->in_reset) {
1030 rxr->bnapi->in_reset = true;1048 rxr->bnapi->in_reset = true;
1031 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);1049 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
1032 schedule_work(&bp->sp_task);1050 bnxt_queue_sp_work(bp);
1033 }1051 }
1034 rxr->rx_next_cons = 0xffff;1052 rxr->rx_next_cons = 0xffff;
1035}1053}
@@ -1717,7 +1735,7 @@ static int bnxt_async_event_process(struct bnxt *bp, · 681 unmodified lines
1717 default:1735 default:
1718 goto async_event_process_exit;1736 goto async_event_process_exit;
1719 }1737 }
1720 schedule_work(&bp->sp_task);1738 bnxt_queue_sp_work(bp);
1721async_event_process_exit:1739async_event_process_exit:
1722 bnxt_ulp_async_events(bp, cmpl);1740 bnxt_ulp_async_events(bp, cmpl);
1723 return 0;1741 return 0;
@@ -1751,7 +1769,7 @@ static int bnxt_hwrm_handler(struct bnxt *bp, struct tx_cmp *txcmp) · 27 unmodified lines
1751 1769
1752 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap);1770 set_bit(vf_id - bp->pf.first_vf_id, bp->pf.vf_event_bmap);
1753 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event);1771 set_bit(BNXT_HWRM_EXEC_FWD_REQ_SP_EVENT, &bp->sp_event);
1754 schedule_work(&bp->sp_task);1772 bnxt_queue_sp_work(bp);
1755 break;1773 break;
1756 1774
1757 case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:1775 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
3448 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false);3466 return bnxt_hwrm_do_send_msg(bp, msg, msg_len, timeout, false);
3449}3467}
3450 3468
3469int _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
3451int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)3475int hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
3452{3476{
3453 int rc;3477 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
6327 }6351 }
6328 6352
6329 if (link_re_init) {6353 if (link_re_init) {
6354 mutex_lock(&bp->link_lock);
6330 rc = bnxt_update_phy_setting(bp);6355 rc = bnxt_update_phy_setting(bp);
6356 mutex_unlock(&bp->link_lock);
6331 if (rc)6357 if (rc)
6332 netdev_warn(bp->dev, "failed to update phy settings\n");6358 netdev_warn(bp->dev, "failed to update phy settings\n");
6333 }6359 }
@@ -6647,7 +6673,7 @@ static void bnxt_set_rx_mode(struct net_device *dev) · 313 unmodified lines
6647 vnic->rx_mask = mask;6673 vnic->rx_mask = mask;
6648 6674
6649 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event);6675 set_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event);
6650 schedule_work(&bp->sp_task);6676 bnxt_queue_sp_work(bp);
6651 }6677 }
6652}6678}
6653 6679
@@ -6920,7 +6946,7 @@ static void bnxt_tx_timeout(struct net_device *dev) · 266 unmodified lines
6920 6946
6921 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n");6947 netdev_err(bp->dev, "TX timeout detected, starting reset task!\n");
6922 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);6948 set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
6923 schedule_work(&bp->sp_task);6949 bnxt_queue_sp_work(bp);
6924}6950}
6925 6951
6926#ifdef CONFIG_NET_POLL_CONTROLLER6952#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -6952,7 +6978,7 @@ static void bnxt_timer(unsigned long data) · 25 unmodified lines
6952 if (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) &&6978 if (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) &&
6953 bp->stats_coal_ticks) {6979 bp->stats_coal_ticks) {
6954 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);6980 set_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);
6955 schedule_work(&bp->sp_task);6981 bnxt_queue_sp_work(bp);
6956 }6982 }
6957bnxt_restart_timer:6983bnxt_restart_timer:
6958 mod_timer(&bp->timer, jiffies + bp->current_interval);6984 mod_timer(&bp->timer, jiffies + bp->current_interval);
@@ -7025,30 +7051,28 @@ static void bnxt_sp_task(struct work_struct *work) · 66 unmodified lines
7025 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))7051 if (test_and_clear_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event))
7026 bnxt_hwrm_port_qstats(bp);7052 bnxt_hwrm_port_qstats(bp);
7027 7053
7028 /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7029 * must be the last functions to be called before exiting.
7030 */
7031 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {7054 if (test_and_clear_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event)) {
7032 int rc = 0;7055 int rc;
7033 7056
7057 mutex_lock(&bp->link_lock);
7034 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,7058 if (test_and_clear_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT,
7035 &bp->sp_event))7059 &bp->sp_event))
7036 bnxt_hwrm_phy_qcaps(bp);7060 bnxt_hwrm_phy_qcaps(bp);
7037 7061
7038 bnxt_rtnl_lock_sp(bp);7062 rc = bnxt_update_link(bp, true);
7039 if (test_bit(BNXT_STATE_OPEN, &bp->state))7063 mutex_unlock(&bp->link_lock);
7040 rc = bnxt_update_link(bp, true);
7041 bnxt_rtnl_unlock_sp(bp);
7042 if (rc)7064 if (rc)
7043 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",7065 netdev_err(bp->dev, "SP task can't update link (rc: %x)\n",
7044 rc);7066 rc);
7045 }7067 }
7046 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {7068 if (test_and_clear_bit(BNXT_HWRM_PORT_MODULE_SP_EVENT, &bp->sp_event)) {
7047 bnxt_rtnl_lock_sp(bp);7069 mutex_lock(&bp->link_lock);
7048 if (test_bit(BNXT_STATE_OPEN, &bp->state))7070 bnxt_get_port_module_status(bp);
7049 bnxt_get_port_module_status(bp);7071 mutex_unlock(&bp->link_lock);
7050 bnxt_rtnl_unlock_sp(bp);
7051 }7072 }
7073 /* These functions below will clear BNXT_STATE_IN_SP_TASK. They
7074 * must be the last functions to be called before exiting.
7075 */
7052 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))7076 if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event))
7053 bnxt_reset(bp, false);7077 bnxt_reset(bp, false);
7054 7078
@@ -7433,7 +7457,7 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, · 378 unmodified lines
7433 spin_unlock_bh(&bp->ntp_fltr_lock);7457 spin_unlock_bh(&bp->ntp_fltr_lock);
7434 7458
7435 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event);7459 set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event);
7436 schedule_work(&bp->sp_task);7460 bnxt_queue_sp_work(bp);
7437 7461
7438 return new_fltr->sw_id;7462 return new_fltr->sw_id;
7439 7463
@@ -7516,7 +7540,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev, · 76 unmodified lines
7516 if (bp->vxlan_port_cnt == 1) {7540 if (bp->vxlan_port_cnt == 1) {
7517 bp->vxlan_port = ti->port;7541 bp->vxlan_port = ti->port;
7518 set_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event);7542 set_bit(BNXT_VXLAN_ADD_PORT_SP_EVENT, &bp->sp_event);
7519 schedule_work(&bp->sp_task);7543 bnxt_queue_sp_work(bp);
7520 }7544 }
7521 break;7545 break;
7522 case UDP_TUNNEL_TYPE_GENEVE:7546 case UDP_TUNNEL_TYPE_GENEVE:
@@ -7533,7 +7557,7 @@ static void bnxt_udp_tunnel_add(struct net_device *dev, · 10 unmodified lines
7533 return;7557 return;
7534 }7558 }
7535 7559
7536 schedule_work(&bp->sp_task);7560 bnxt_queue_sp_work(bp);
7537}7561}
7538 7562
7539static void bnxt_udp_tunnel_del(struct net_device *dev,7563static 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
7572 return;7596 return;
7573 }7597 }
7574 7598
7575 schedule_work(&bp->sp_task);7599 bnxt_queue_sp_work(bp);
7576}7600}
7577 7601
7578static int bnxt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,7602static 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
7720 pci_disable_pcie_error_reporting(pdev);7744 pci_disable_pcie_error_reporting(pdev);
7721 unregister_netdev(dev);7745 unregister_netdev(dev);
7722 bnxt_shutdown_tc(bp);7746 bnxt_shutdown_tc(bp);
7723 cancel_work_sync(&bp->sp_task);7747 bnxt_cancel_sp_work(bp);
7724 bp->sp_event = 0;7748 bp->sp_event = 0;
7725 7749
7726 bnxt_clear_int_mode(bp);7750 bnxt_clear_int_mode(bp);
@@ -7748,6 +7772,7 @@ static int bnxt_probe_phy(struct bnxt *bp) · 21 unmodified lines
7748 rc);7772 rc);
7749 return rc;7773 return rc;
7750 }7774 }
7775 mutex_init(&bp->link_lock);
7751 7776
7752 rc = bnxt_update_link(bp, false);7777 rc = bnxt_update_link(bp, false);
7753 if (rc) {7778 if (rc) {
@@ -7946,7 +7971,7 @@ static void bnxt_parse_log_pcie_link(struct bnxt *bp) · 192 unmodified lines
7946 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;7971 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
7947 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;7972 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
7948 7973
7949 if (pcie_get_minimum_link(bp->pdev, &speed, &width) ||7974 if (pcie_get_minimum_link(pci_physfn(bp->pdev), &speed, &width) ||
7950 speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)7975 speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN)
7951 netdev_info(bp->dev, "Failed to determine PCIe Link Info\n");7976 netdev_info(bp->dev, "Failed to determine PCIe Link Info\n");
7952 else7977 else
@@ -8138,8 +8163,17 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 185 unmodified lines
8138 else8163 else
8139 device_set_wakeup_capable(&pdev->dev, false);8164 device_set_wakeup_capable(&pdev->dev, false);
8140 8165
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 }
8142 bnxt_init_tc(bp);8175 bnxt_init_tc(bp);
8176 }
8143 8177
8144 rc = register_netdev(dev);8178 rc = register_netdev(dev);
8145 if (rc)8179 if (rc)
@@ -8375,4 +8409,17 @@ static struct pci_driver bnxt_pci_driver = { · 229 unmodified lines
8375#endif8409#endif
8376};8410};
8377 8411
8378module_pci_driver(bnxt_pci_driver);8412static int __init bnxt_init(void)
8413{
8414 return pci_register_driver(&bnxt_pci_driver);
8415}
8416
8417static 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
8424module_init(bnxt_init);
8425module_exit(bnxt_exit);
drivers/net/ethernet/broadcom/bnxt/bnxt.h+5−0
@@ -1290,6 +1290,10 @@ struct bnxt { · 1289 unmodified lines
1290 unsigned long *ntp_fltr_bmap;1290 unsigned long *ntp_fltr_bmap;
1291 int ntp_fltr_count;1291 int ntp_fltr_count;
1292 1292
1293 /* To protect link related settings during link changes and
1294 * ethtool settings changes.
1295 */
1296 struct mutex link_lock;
1293 struct bnxt_link_info link_info;1297 struct bnxt_link_info link_info;
1294 struct ethtool_eee eee;1298 struct ethtool_eee eee;
1295 u32 lpi_tmr_lo;1299 u32 lpi_tmr_lo;
@@ -1358,6 +1362,7 @@ void bnxt_set_ring_params(struct bnxt *); · 62 unmodified lines
1358int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);1362int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
1359void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);1363void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);
1360int _hwrm_send_message(struct bnxt *, void *, u32, int);1364int _hwrm_send_message(struct bnxt *, void *, u32, int);
1365int _hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 len, int timeout);
1361int hwrm_send_message(struct bnxt *, void *, u32, int);1366int hwrm_send_message(struct bnxt *, void *, u32, int);
1362int hwrm_send_message_silent(struct bnxt *, void *, u32, int);1367int hwrm_send_message_silent(struct bnxt *, void *, u32, int);
1363int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,1368int 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
50 50
51 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1);51 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1);
52 req.flags = cpu_to_le32(QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN);52 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);
54 if (!rc) {56 if (!rc) {
55 u8 *pri2cos = &resp->pri0_cos_queue_id;57 u8 *pri2cos = &resp->pri0_cos_queue_id;
56 int i, j;58 int i, j;
@@ -66,6 +68,7 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 9 unmodified lines
66 }68 }
67 }69 }
68 }70 }
71 mutex_unlock(&bp->hwrm_cmd_lock);
69 return rc;72 return rc;
70}73}
71 74
@@ -119,9 +122,13 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) · 47 unmodified lines
119 int rc, i;122 int rc, i;
120 123
121 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_QCFG, -1, -1);124 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);125
123 if (rc)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);
124 return rc;130 return rc;
131 }
125 132
126 data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);133 data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);
127 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) {134 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
143 }150 }
144 }151 }
145 }152 }
153 mutex_unlock(&bp->hwrm_cmd_lock);
146 return 0;154 return 0;
147}155}
148 156
@@ -240,12 +248,17 @@ static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc) · 91 unmodified lines
240 int rc;248 int rc;
241 249
242 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_QCFG, -1, -1);250 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);251
244 if (rc)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);
245 return rc;256 return rc;
257 }
246 258
247 pri_mask = le32_to_cpu(resp->flags);259 pri_mask = le32_to_cpu(resp->flags);
248 pfc->pfc_en = pri_mask;260 pfc->pfc_en = pri_mask;
261 mutex_unlock(&bp->hwrm_cmd_lock);
249 return 0;262 return 0;
250}263}
251 264
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
1052 u32 ethtool_speed;1052 u32 ethtool_speed;
1053 1053
1054 ethtool_link_ksettings_zero_link_mode(lk_ksettings, supported);1054 ethtool_link_ksettings_zero_link_mode(lk_ksettings, supported);
1055 mutex_lock(&bp->link_lock);
1055 bnxt_fw_to_ethtool_support_spds(link_info, lk_ksettings);1056 bnxt_fw_to_ethtool_support_spds(link_info, lk_ksettings);
1056 1057
1057 ethtool_link_ksettings_zero_link_mode(lk_ksettings, advertising);1058 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
1099 base->port = PORT_FIBRE;1100 base->port = PORT_FIBRE;
1100 }1101 }
1101 base->phy_address = link_info->phy_addr;1102 base->phy_address = link_info->phy_addr;
1103 mutex_unlock(&bp->link_lock);
1102 1104
1103 return 0;1105 return 0;
1104}1106}
@@ -1190,6 +1192,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev, · 85 unmodified lines
1190 if (!BNXT_SINGLE_PF(bp))1192 if (!BNXT_SINGLE_PF(bp))
1191 return -EOPNOTSUPP;1193 return -EOPNOTSUPP;
1192 1194
1195 mutex_lock(&bp->link_lock);
1193 if (base->autoneg == AUTONEG_ENABLE) {1196 if (base->autoneg == AUTONEG_ENABLE) {
1194 BNXT_ETHTOOL_TO_FW_SPDS(fw_advertising, lk_ksettings,1197 BNXT_ETHTOOL_TO_FW_SPDS(fw_advertising, lk_ksettings,
1195 advertising);1198 advertising);
@@ -1234,6 +1237,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev, · 38 unmodified lines
1234 rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);1237 rc = bnxt_hwrm_set_link_setting(bp, set_pause, false);
1235 1238
1236set_setting_exit:1239set_setting_exit:
1240 mutex_unlock(&bp->link_lock);
1237 return rc;1241 return rc;
1238}1242}
1239 1243
@@ -1805,7 +1809,8 @@ static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal, · 565 unmodified lines
1805 req.dir_ordinal = cpu_to_le16(ordinal);1809 req.dir_ordinal = cpu_to_le16(ordinal);
1806 req.dir_ext = cpu_to_le16(ext);1810 req.dir_ext = cpu_to_le16(ext);
1807 req.opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ;1811 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);
1809 if (rc == 0) {1814 if (rc == 0) {
1810 if (index)1815 if (index)
1811 *index = le16_to_cpu(output->dir_idx);1816 *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
1814 if (data_length)1819 if (data_length)
1815 *data_length = le32_to_cpu(output->dir_data_length);1820 *data_length = le32_to_cpu(output->dir_data_length);
1816 }1821 }
1822 mutex_unlock(&bp->hwrm_cmd_lock);
1817 return rc;1823 return rc;
1818}1824}
1819 1825
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
502 int rc = 0, vfs_supported;502 int rc = 0, vfs_supported;
503 int min_rx_rings, min_tx_rings, min_rss_ctxs;503 int min_rx_rings, min_tx_rings, min_rss_ctxs;
504 int tx_ok = 0, rx_ok = 0, rss_ok = 0;504 int tx_ok = 0, rx_ok = 0, rss_ok = 0;
505 int avail_cp, avail_stat;
505 506
506 /* Check if we can enable requested num of vf's. At a mininum507 /* Check if we can enable requested num of vf's. At a mininum
507 * we require 1 RX 1 TX rings for each VF. In this minimum conf508 * 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
509 */510 */
510 vfs_supported = *num_vfs;511 vfs_supported = *num_vfs;
511 512
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
512 while (vfs_supported) {517 while (vfs_supported) {
513 min_rx_rings = vfs_supported;518 min_rx_rings = vfs_supported;
514 min_tx_rings = vfs_supported;519 min_tx_rings = vfs_supported;
@@ -523,10 +528,12 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) · 8 unmodified lines
523 min_rx_rings)528 min_rx_rings)
524 rx_ok = 1;529 rx_ok = 1;
525 }530 }
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)
527 rx_ok = 0;533 rx_ok = 0;
528 534
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)
530 tx_ok = 1;537 tx_ok = 1;
531 538
532 if (bp->pf.max_rsscos_ctxs - bp->rsscos_nr_ctxs >= min_rss_ctxs)539 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
1847 struct lio *lio = container_of(ptp, struct lio, ptp_info);1847 struct lio *lio = container_of(ptp, struct lio, ptp_info);
1848 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;1848 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;
1849 1849
1850 ns = timespec_to_ns(ts);1850 ns = timespec64_to_ns(ts);
1851 1851
1852 spin_lock_irqsave(&lio->ptp_lock, flags);1852 spin_lock_irqsave(&lio->ptp_lock, flags);
1853 lio_pci_writeq(oct, ns, CN6XXX_MIO_PTP_CLOCK_HI);1853 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
1093 * places them in a descriptor array, scrq_arr1093 * places them in a descriptor array, scrq_arr
1094 */1094 */
1095 1095
1096static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,1096static int create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len,
1097 union sub_crq *scrq_arr)1097 union sub_crq *scrq_arr)
1098{1098{
1099 union sub_crq hdr_desc;1099 union sub_crq hdr_desc;
1100 int tmp_len = len;1100 int tmp_len = len;
1101 int num_descs = 0;
1101 u8 *data, *cur;1102 u8 *data, *cur;
1102 int tmp;1103 int tmp;
1103 1104
@@ -1126,7 +1127,10 @@ static void create_hdr_descs(u8 hdr_field, u8 *hdr_data, int len, int *hdr_len, · 22 unmodified lines
1126 tmp_len -= tmp;1127 tmp_len -= tmp;
1127 *scrq_arr = hdr_desc;1128 *scrq_arr = hdr_desc;
1128 scrq_arr++;1129 scrq_arr++;
1130 num_descs++;
1129 }1131 }
1132
1133 return num_descs;
1130}1134}
1131 1135
1132/**1136/**
@@ -1144,16 +1148,12 @@ static void build_hdr_descs_arr(struct ibmvnic_tx_buff *txbuff, · 11 unmodified lines
1144 int *num_entries, u8 hdr_field)1148 int *num_entries, u8 hdr_field)
1145{1149{
1146 int hdr_len[3] = {0, 0, 0};1150 int hdr_len[3] = {0, 0, 0};
1147 int tot_len, len;1151 int tot_len;
1148 u8 *hdr_data = txbuff->hdr_data;1152 u8 *hdr_data = txbuff->hdr_data;
1149 1153
1150 tot_len = build_hdr_data(hdr_field, txbuff->skb, hdr_len,1154 tot_len = build_hdr_data(hdr_field, txbuff->skb, hdr_len,
1151 txbuff->hdr_data);1155 txbuff->hdr_data);
1152 len = tot_len;1156 *num_entries += create_hdr_descs(hdr_field, hdr_data, tot_len, hdr_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,
1157 txbuff->indir_arr + 1);1157 txbuff->indir_arr + 1);
1158}1158}
1159 1159
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
298}298}
299 299
300/**300/**
301 * __i40e_read_nvm_word - Reads nvm word, assumes called does the locking301 * __i40e_read_nvm_word - Reads nvm word, assumes caller does the locking
302 * @hw: pointer to the HW structure302 * @hw: pointer to the HW structure
303 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)303 * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
304 * @data: word read from the Shadow RAM304 * @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
1037 return false;1037 return false;
1038}1038}
1039 1039
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 **/
1047static 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
1040/**1066/**
1041 * i40e_rx_is_programming_status - check for programming status descriptor1067 * i40e_rx_is_programming_status - check for programming status descriptor
1042 * @qw: qword representing status_error_len in CPU ordering1068 * @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
1071 union i40e_rx_desc *rx_desc,1097 union i40e_rx_desc *rx_desc,
1072 u64 qw)1098 u64 qw)
1073{1099{
1074 u32 ntc = rx_ring->next_to_clean + 1;1100 struct i40e_rx_buffer *rx_buffer;
1101 u32 ntc = rx_ring->next_to_clean;
1075 u8 id;1102 u8 id;
1076 1103
1077 /* fetch, update, and store next to clean */1104 /* fetch, update, and store next to clean */
1105 rx_buffer = &rx_ring->rx_bi[ntc++];
1078 ntc = (ntc < rx_ring->count) ? ntc : 0;1106 ntc = (ntc < rx_ring->count) ? ntc : 0;
1079 rx_ring->next_to_clean = ntc;1107 rx_ring->next_to_clean = ntc;
1080 1108
1081 prefetch(I40E_RX_DESC(rx_ring, ntc));1109 prefetch(I40E_RX_DESC(rx_ring, ntc));
1082 1110
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
1083 id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >>1118 id = (qw & I40E_RX_PROG_STATUS_DESC_QW1_PROGID_MASK) >>
1084 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;1119 I40E_RX_PROG_STATUS_DESC_QW1_PROGID_SHIFT;
1085 1120
@@ -1638,32 +1673,6 @@ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb, · 552 unmodified lines
1638 return false;1673 return false;
1639}1674}
1640 1675
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 **/
1648static 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
1667/**1676/**
1668 * i40e_page_is_reusable - check if any reuse is possible1677 * i40e_page_is_reusable - check if any reuse is possible
1669 * @page: page struct to check1678 * @page: page struct to check
drivers/net/ethernet/mellanox/mlxsw/core.c+10−1
@@ -96,6 +96,7 @@ struct mlxsw_core { · 95 unmodified lines
96 const struct mlxsw_bus *bus;96 const struct mlxsw_bus *bus;
97 void *bus_priv;97 void *bus_priv;
98 const struct mlxsw_bus_info *bus_info;98 const struct mlxsw_bus_info *bus_info;
99 struct workqueue_struct *emad_wq;
99 struct list_head rx_listener_list;100 struct list_head rx_listener_list;
100 struct list_head event_listener_list;101 struct list_head event_listener_list;
101 struct {102 struct {
@@ -465,7 +466,7 @@ static void mlxsw_emad_trans_timeout_schedule(struct mlxsw_reg_trans *trans) · 363 unmodified lines
465{466{
466 unsigned long timeout = msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS);467 unsigned long timeout = msecs_to_jiffies(MLXSW_EMAD_TIMEOUT_MS);
467 468
468 mlxsw_core_schedule_dw(&trans->timeout_dw, timeout);469 queue_delayed_work(trans->core->emad_wq, &trans->timeout_dw, timeout);
469}470}
470 471
471static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,472static 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
587 588
588static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)589static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core)
589{590{
591 struct workqueue_struct *emad_wq;
590 u64 tid;592 u64 tid;
591 int err;593 int err;
592 594
593 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))595 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX))
594 return 0;596 return 0;
595 597
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
596 /* Set the upper 32 bits of the transaction ID field to a random603 /* Set the upper 32 bits of the transaction ID field to a random
597 * number. This allows us to discard EMADs addressed to other604 * number. This allows us to discard EMADs addressed to other
598 * devices.605 * devices.
@@ -619,6 +626,7 @@ static int mlxsw_emad_init(struct mlxsw_core *mlxsw_core) · 20 unmodified lines
619err_emad_trap_set:626err_emad_trap_set:
620 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,627 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
621 mlxsw_core);628 mlxsw_core);
629 destroy_workqueue(mlxsw_core->emad_wq);
622 return err;630 return err;
623}631}
624 632
@@ -631,6 +639,7 @@ static void mlxsw_emad_fini(struct mlxsw_core *mlxsw_core) · 6 unmodified lines
631 mlxsw_core->emad.use_emad = false;639 mlxsw_core->emad.use_emad = false;
632 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,640 mlxsw_core_trap_unregister(mlxsw_core, &mlxsw_emad_rx_listener,
633 mlxsw_core);641 mlxsw_core);
642 destroy_workqueue(mlxsw_core->emad_wq);
634}643}
635 644
636static struct sk_buff *mlxsw_emad_alloc(const struct mlxsw_core *mlxsw_core,645static 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
6401 mlxsw_reg_mgpc_opcode_set(payload, opcode);6401 mlxsw_reg_mgpc_opcode_set(payload, opcode);
6402}6402}
6403 6403
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
6411MLXSW_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 */
6418MLXSW_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 */
6425MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
6426
6427static 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
6404/* SBPR - Shared Buffer Pools Register6434/* SBPR - Shared Buffer Pools Register
6405 * -----------------------------------6435 * -----------------------------------
6406 * The SBPR configures and retrieves the shared buffer pools and configuration.6436 * 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
6881 MLXSW_REG(mcc),6911 MLXSW_REG(mcc),
6882 MLXSW_REG(mcda),6912 MLXSW_REG(mcda),
6883 MLXSW_REG(mgpc),6913 MLXSW_REG(mgpc),
6914 MLXSW_REG(tigcr),
6884 MLXSW_REG(sbpr),6915 MLXSW_REG(sbpr),
6885 MLXSW_REG(sbcm),6916 MLXSW_REG(sbcm),
6886 MLXSW_REG(sbpm),6917 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
5896 kfree(mlxsw_sp->router->rifs);5896 kfree(mlxsw_sp->router->rifs);
5897}5897}
5898 5898
5899static int
5900mlxsw_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
5899static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)5908static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp)
5900{5909{
5901 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;5910 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr;
5902 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list);5911 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list);
5903 return 0;5912 return mlxsw_sp_ipip_config_tigcr(mlxsw_sp);
5904}5913}
5905 5914
5906static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp)5915static 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
1180{1180{
1181 void *frag;1181 void *frag;
1182 1182
1183 if (!dp->xdp_prog)1183 if (!dp->xdp_prog) {
1184 frag = netdev_alloc_frag(dp->fl_bufsz);1184 frag = netdev_alloc_frag(dp->fl_bufsz);
1185 else1185 } else {
1186 frag = page_address(alloc_page(GFP_KERNEL | __GFP_COLD));1186 struct page *page;
1187
1188 page = alloc_page(GFP_KERNEL | __GFP_COLD);
1189 frag = page ? page_address(page) : NULL;
1190 }
1187 if (!frag) {1191 if (!frag) {
1188 nn_dp_warn(dp, "Failed to alloc receive page frag\n");1192 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
1189 return NULL;1193 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
1203{1207{
1204 void *frag;1208 void *frag;
1205 1209
1206 if (!dp->xdp_prog)1210 if (!dp->xdp_prog) {
1207 frag = napi_alloc_frag(dp->fl_bufsz);1211 frag = napi_alloc_frag(dp->fl_bufsz);
1208 else1212 } else {
1209 frag = page_address(alloc_page(GFP_ATOMIC | __GFP_COLD));1213 struct page *page;
1214
1215 page = alloc_page(GFP_ATOMIC | __GFP_COLD);
1216 frag = page ? page_address(page) : NULL;
1217 }
1210 if (!frag) {1218 if (!frag) {
1211 nn_dp_warn(dp, "Failed to alloc receive page frag\n");1219 nn_dp_warn(dp, "Failed to alloc receive page frag\n");
1212 return NULL;1220 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
464 464
465 do {465 do {
466 start = u64_stats_fetch_begin(&nn->r_vecs[i].rx_sync);466 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;
468 tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;468 tmp[0] = nn->r_vecs[i].hw_csum_rx_ok;
469 tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;469 tmp[1] = nn->r_vecs[i].hw_csum_rx_inner_ok;
470 tmp[2] = nn->r_vecs[i].hw_csum_rx_error;470 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
472 472
473 do {473 do {
474 start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);474 start = u64_stats_fetch_begin(&nn->r_vecs[i].tx_sync);
475 *data++ = nn->r_vecs[i].tx_pkts;475 data[1] = nn->r_vecs[i].tx_pkts;
476 *data++ = nn->r_vecs[i].tx_busy;476 data[2] = nn->r_vecs[i].tx_busy;
477 tmp[3] = nn->r_vecs[i].hw_csum_tx;477 tmp[3] = nn->r_vecs[i].hw_csum_tx;
478 tmp[4] = nn->r_vecs[i].hw_csum_tx_inner;478 tmp[4] = nn->r_vecs[i].hw_csum_tx_inner;
479 tmp[5] = nn->r_vecs[i].tx_gather;479 tmp[5] = nn->r_vecs[i].tx_gather;
480 tmp[6] = nn->r_vecs[i].tx_lso;480 tmp[6] = nn->r_vecs[i].tx_lso;
481 } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));481 } while (u64_stats_fetch_retry(&nn->r_vecs[i].tx_sync, start));
482 482
483 data += 3;
484
483 for (j = 0; j < NN_ET_RVEC_GATHER_STATS; j++)485 for (j = 0; j < NN_ET_RVEC_GATHER_STATS; j++)
484 gathered_stats[j] += tmp[j];486 gathered_stats[j] += tmp[j];
485 }487 }
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
8491 rtl8168_driver_start(tp);8491 rtl8168_driver_start(tp);
8492 }8492 }
8493 8493
8494 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
8495
8496 if (pci_dev_run_wake(pdev))8494 if (pci_dev_run_wake(pdev))
8497 pm_runtime_put_noidle(&pdev->dev);8495 pm_runtime_put_noidle(&pdev->dev);
8498 8496
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
275 goto exit;275 goto exit;
276 i++;276 i++;
277 277
278 } while ((ret == 1) || (i < 10));278 } while ((ret == 1) && (i < 10));
279 279
280 if (i == 10)280 if (i == 10)
281 ret = -EBUSY;281 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
34 34
35 err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,35 err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
36 !(value & DMA_BUS_MODE_SFT_RESET),36 !(value & DMA_BUS_MODE_SFT_RESET),
37 100000, 10000);37 10000, 100000);
38 if (err)38 if (err)
39 return -EBUSY;39 return -EBUSY;
40 40
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
473 struct dma_desc *np, struct sk_buff *skb)473 struct dma_desc *np, struct sk_buff *skb)
474{474{
475 struct skb_shared_hwtstamps *shhwtstamp = NULL;475 struct skb_shared_hwtstamps *shhwtstamp = NULL;
476 struct dma_desc *desc = p;
476 u64 ns;477 u64 ns;
477 478
478 if (!priv->hwts_rx_en)479 if (!priv->hwts_rx_en)
479 return;480 return;
481 /* For GMAC4, the valid timestamp is from CTX next desc. */
482 if (priv->plat->has_gmac4)
483 desc = np;
480 484
481 /* Check if timestamp is available */485 /* Check if timestamp is available */
482 if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) {486 if (priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) {
483 /* For GMAC4, the valid timestamp is from CTX next desc. */487 ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
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
489 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);488 netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
490 shhwtstamp = skb_hwtstamps(skb);489 shhwtstamp = skb_hwtstamps(skb);
491 memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));490 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
1800{1799{
1801 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];1800 struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue];
1802 unsigned int bytes_compl = 0, pkts_compl = 0;1801 unsigned int bytes_compl = 0, pkts_compl = 0;
1803 unsigned int entry = tx_q->dirty_tx;1802 unsigned int entry;
1804 1803
1805 netif_tx_lock(priv->dev);1804 netif_tx_lock(priv->dev);
1806 1805
1807 priv->xstats.tx_clean++;1806 priv->xstats.tx_clean++;
1808 1807
1808 entry = tx_q->dirty_tx;
1809 while (entry != tx_q->cur_tx) {1809 while (entry != tx_q->cur_tx) {
1810 struct sk_buff *skb = tx_q->tx_skbuff[entry];1810 struct sk_buff *skb = tx_q->tx_skbuff[entry];
1811 struct dma_desc *p;1811 struct dma_desc *p;
@@ -3333,6 +3333,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) · 1521 unmodified lines
3333 * them in stmmac_rx_refill() function so that3333 * them in stmmac_rx_refill() function so that
3334 * device can reuse it.3334 * device can reuse it.
3335 */3335 */
3336 dev_kfree_skb_any(rx_q->rx_skbuff[entry]);
3336 rx_q->rx_skbuff[entry] = NULL;3337 rx_q->rx_skbuff[entry] = NULL;
3337 dma_unmap_single(priv->device,3338 dma_unmap_single(priv->device,
3338 rx_q->rx_skbuff_dma[entry],3339 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
113 113
114static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni)114static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni)
115{115{
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
121 return !memcmp(vni, &tun_id[5], 3);116 return !memcmp(vni, &tun_id[5], 3);
122#endif
123}117}
124 118
125static sa_family_t geneve_get_sk_family(struct geneve_sock *gs)119static 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
742 sg_init_table(sg, ret);742 sg_init_table(sg, ret);
743 ret = skb_to_sgvec(skb, sg, 0, skb->len);743 ret = skb_to_sgvec(skb, sg, 0, skb->len);
744 if (unlikely(ret < 0)) {744 if (unlikely(ret < 0)) {
745 aead_request_free(req);
745 macsec_txsa_put(tx_sa);746 macsec_txsa_put(tx_sa);
746 kfree_skb(skb);747 kfree_skb(skb);
747 return ERR_PTR(ret);748 return ERR_PTR(ret);
@@ -954,6 +955,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb, · 206 unmodified lines
954 sg_init_table(sg, ret);955 sg_init_table(sg, ret);
955 ret = skb_to_sgvec(skb, sg, 0, skb->len);956 ret = skb_to_sgvec(skb, sg, 0, skb->len);
956 if (unlikely(ret < 0)) {957 if (unlikely(ret < 0)) {
958 aead_request_free(req);
957 kfree_skb(skb);959 kfree_skb(skb);
958 return ERR_PTR(ret);960 return ERR_PTR(ret);
959 }961 }
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
2027 2027
2028 if (!dev)2028 if (!dev)
2029 return -ENOMEM;2029 return -ENOMEM;
2030 err = dev_get_valid_name(net, dev, name);
2031 if (err)
2032 goto err_free_dev;
2030 2033
2031 dev_net_set(dev, net);2034 dev_net_set(dev, net);
2032 dev->rtnl_link_ops = &tun_link_ops;2035 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
652 struct device *dev = i2400m_dev(i2400m);652 struct device *dev = i2400m_dev(i2400m);
653 struct {653 struct {
654 struct i2400m_bootrom_header cmd;654 struct i2400m_bootrom_header cmd;
655 u8 cmd_payload[chunk_len];655 u8 cmd_payload[];
656 } __packed *buf;656 } __packed *buf;
657 struct i2400m_bootrom_header ack;657 struct i2400m_bootrom_header ack;
658 658
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
429 if (code != BRCMF_E_IF && !fweh->evt_handler[code])429 if (code != BRCMF_E_IF && !fweh->evt_handler[code])
430 return;430 return;
431 431
432 if (datalen > BRCMF_DCMD_MAXLEN)432 if (datalen > BRCMF_DCMD_MAXLEN ||
433 datalen + sizeof(*event_packet) > packet_len)
433 return;434 return;
434 435
435 if (in_interrupt())436 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
14764}14764}
14765 14765
14766static void14766static void
14767wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, u8 *events, u8 *dlys,14767wlc_phy_set_rfseq_nphy(struct brcms_phy *pi, u8 cmd, const u8 *events,
14768 u8 len)14768 const u8 *dlys, u8 len)
14769{14769{
14770 u32 t1_offset, t2_offset;14770 u32 t1_offset, t2_offset;
14771 u8 ctr;14771 u8 ctr;
@@ -15240,16 +15240,16 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev5(struct brcms_phy *pi) · 468 unmodified lines
15240static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)15240static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi)
15241{15241{
15242 u16 currband;15242 u16 currband;
15243 s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };15243 static const s8 lna1G_gain_db_rev7[] = { 9, 14, 19, 24 };
15244 s8 *lna1_gain_db = NULL;15244 const s8 *lna1_gain_db = NULL;
15245 s8 *lna1_gain_db_2 = NULL;15245 const s8 *lna1_gain_db_2 = NULL;
15246 s8 *lna2_gain_db = NULL;15246 const s8 *lna2_gain_db = NULL;
15247 s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };15247 static const s8 tiaA_gain_db_rev7[] = { -9, -6, -3, 0, 3, 3, 3, 3, 3, 3 };
15248 s8 *tia_gain_db;15248 const s8 *tia_gain_db;
15249 s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };15249 static const s8 tiaA_gainbits_rev7[] = { 0, 1, 2, 3, 4, 4, 4, 4, 4, 4 };
15250 s8 *tia_gainbits;15250 const s8 *tia_gainbits;
15251 u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };15251 static const u16 rfseqA_init_gain_rev7[] = { 0x624f, 0x624f };
15252 u16 *rfseq_init_gain;15252 const u16 *rfseq_init_gain;
15253 u16 init_gaincode;15253 u16 init_gaincode;
15254 u16 clip1hi_gaincode;15254 u16 clip1hi_gaincode;
15255 u16 clip1md_gaincode = 0;15255 u16 clip1md_gaincode = 0;
@@ -15310,10 +15310,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) · 54 unmodified lines
15310 15310
15311 if ((freq <= 5080) || (freq == 5825)) {15311 if ((freq <= 5080) || (freq == 5825)) {
15312 15312
15313 s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };15313 static const s8 lna1A_gain_db_rev7[] = { 11, 16, 20, 24 };
15314 s8 lna1A_gain_db_2_rev7[] = {15314 static const s8 lna1A_gain_db_2_rev7[] = { 11, 17, 22, 25};
15315 11, 17, 22, 25};15315 static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15316 s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15317 15316
15318 crsminu_th = 0x3e;15317 crsminu_th = 0x3e;
15319 lna1_gain_db = lna1A_gain_db_rev7;15318 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
15321 lna2_gain_db = lna2A_gain_db_rev7;15320 lna2_gain_db = lna2A_gain_db_rev7;
15322 } else if ((freq >= 5500) && (freq <= 5700)) {15321 } else if ((freq >= 5500) && (freq <= 5700)) {
15323 15322
15324 s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };15323 static const s8 lna1A_gain_db_rev7[] = { 11, 17, 21, 25 };
15325 s8 lna1A_gain_db_2_rev7[] = {15324 static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15326 12, 18, 22, 26};15325 static const s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
15327 s8 lna2A_gain_db_rev7[] = { 1, 8, 12, 16 };
15328 15326
15329 crsminu_th = 0x45;15327 crsminu_th = 0x45;
15330 clip1md_gaincode_B = 0x14;15328 clip1md_gaincode_B = 0x14;
@@ -15335,10 +15333,9 @@ static void wlc_phy_workarounds_nphy_gainctrl_2057_rev6(struct brcms_phy *pi) · 4 unmodified lines
15335 lna2_gain_db = lna2A_gain_db_rev7;15333 lna2_gain_db = lna2A_gain_db_rev7;
15336 } else {15334 } else {
15337 15335
15338 s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };15336 static const s8 lna1A_gain_db_rev7[] = { 12, 18, 22, 26 };
15339 s8 lna1A_gain_db_2_rev7[] = {15337 static const s8 lna1A_gain_db_2_rev7[] = { 12, 18, 22, 26};
15340 12, 18, 22, 26};15338 static const s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15341 s8 lna2A_gain_db_rev7[] = { -1, 6, 10, 14 };
15342 15339
15343 crsminu_th = 0x41;15340 crsminu_th = 0x41;
15344 lna1_gain_db = lna1A_gain_db_rev7;15341 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
15450 NPHY_RFSEQ_CMD_CLR_HIQ_DIS,15447 NPHY_RFSEQ_CMD_CLR_HIQ_DIS,
15451 NPHY_RFSEQ_CMD_SET_HPF_BW15448 NPHY_RFSEQ_CMD_SET_HPF_BW
15452 };15449 };
15453 u8 rfseq_updategainu_dlys[] = { 10, 30, 1 };15450 static const u8 rfseq_updategainu_dlys[] = { 10, 30, 1 };
15454 s8 lna1G_gain_db[] = { 7, 11, 16, 23 };15451 static const s8 lna1G_gain_db[] = { 7, 11, 16, 23 };
15455 s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 };15452 static const s8 lna1G_gain_db_rev4[] = { 8, 12, 17, 25 };
15456 s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 };15453 static const s8 lna1G_gain_db_rev5[] = { 9, 13, 18, 26 };
15457 s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 };15454 static const s8 lna1G_gain_db_rev6[] = { 8, 13, 18, 25 };
15458 s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 };15455 static const s8 lna1G_gain_db_rev6_224B0[] = { 10, 14, 19, 27 };
15459 s8 lna1A_gain_db[] = { 7, 11, 17, 23 };15456 static const s8 lna1A_gain_db[] = { 7, 11, 17, 23 };
15460 s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 };15457 static const s8 lna1A_gain_db_rev4[] = { 8, 12, 18, 23 };
15461 s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 };15458 static const s8 lna1A_gain_db_rev5[] = { 6, 10, 16, 21 };
15462 s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 };15459 static const s8 lna1A_gain_db_rev6[] = { 6, 10, 16, 21 };
15463 s8 *lna1_gain_db = NULL;15460 const s8 *lna1_gain_db = NULL;
15464 s8 lna2G_gain_db[] = { -5, 6, 10, 14 };15461 static const s8 lna2G_gain_db[] = { -5, 6, 10, 14 };
15465 s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 };15462 static const s8 lna2G_gain_db_rev5[] = { -3, 7, 11, 16 };
15466 s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 };15463 static const s8 lna2G_gain_db_rev6[] = { -5, 6, 10, 14 };
15467 s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 };15464 static const s8 lna2G_gain_db_rev6_224B0[] = { -5, 6, 10, 15 };
15468 s8 lna2A_gain_db[] = { -6, 2, 6, 10 };15465 static const s8 lna2A_gain_db[] = { -6, 2, 6, 10 };
15469 s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 };15466 static const s8 lna2A_gain_db_rev4[] = { -5, 2, 6, 10 };
15470 s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 };15467 static const s8 lna2A_gain_db_rev5[] = { -7, 0, 4, 8 };
15471 s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 };15468 static const s8 lna2A_gain_db_rev6[] = { -7, 0, 4, 8 };
15472 s8 *lna2_gain_db = NULL;15469 const s8 *lna2_gain_db = NULL;
15473 s8 tiaG_gain_db[] = {15470 static const s8 tiaG_gain_db[] = {
15474 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };15471 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };
15475 s8 tiaA_gain_db[] = {15472 static const s8 tiaA_gain_db[] = {
15476 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 };15473 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 };
15477 s8 tiaA_gain_db_rev4[] = {15474 static const s8 tiaA_gain_db_rev4[] = {
15478 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };15475 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15479 s8 tiaA_gain_db_rev5[] = {15476 static const s8 tiaA_gain_db_rev5[] = {
15480 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };15477 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15481 s8 tiaA_gain_db_rev6[] = {15478 static const s8 tiaA_gain_db_rev6[] = {
15482 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };15479 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d };
15483 s8 *tia_gain_db;15480 const s8 *tia_gain_db;
15484 s8 tiaG_gainbits[] = {15481 static const s8 tiaG_gainbits[] = {
15485 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };15482 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
15486 s8 tiaA_gainbits[] = {15483 static const s8 tiaA_gainbits[] = {
15487 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 };15484 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06 };
15488 s8 tiaA_gainbits_rev4[] = {15485 static const s8 tiaA_gainbits_rev4[] = {
15489 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };15486 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15490 s8 tiaA_gainbits_rev5[] = {15487 static const s8 tiaA_gainbits_rev5[] = {
15491 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };15488 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15492 s8 tiaA_gainbits_rev6[] = {15489 static const s8 tiaA_gainbits_rev6[] = {
15493 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };15490 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
15494 s8 *tia_gainbits;15491 const s8 *tia_gainbits;
15495 s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 };15492 static const s8 lpf_gain_db[] = { 0x00, 0x06, 0x0c, 0x12, 0x12, 0x12 };
15496 s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 };15493 static const s8 lpf_gainbits[] = { 0x00, 0x01, 0x02, 0x03, 0x03, 0x03 };
15497 u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f };15494 static const u16 rfseqG_init_gain[] = { 0x613f, 0x613f, 0x613f, 0x613f };
15498 u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f };15495 static const u16 rfseqG_init_gain_rev4[] = { 0x513f, 0x513f, 0x513f, 0x513f };
15499 u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f };15496 static const u16 rfseqG_init_gain_rev5[] = { 0x413f, 0x413f, 0x413f, 0x413f };
15500 u16 rfseqG_init_gain_rev5_elna[] = {15497 static const u16 rfseqG_init_gain_rev5_elna[] = {
15501 0x013f, 0x013f, 0x013f, 0x013f };15498 0x013f, 0x013f, 0x013f, 0x013f };
15502 u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f };15499 static const u16 rfseqG_init_gain_rev6[] = { 0x513f, 0x513f };
15503 u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f };15500 static const u16 rfseqG_init_gain_rev6_224B0[] = { 0x413f, 0x413f };
15504 u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f };15501 static const u16 rfseqG_init_gain_rev6_elna[] = { 0x113f, 0x113f };
15505 u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f };15502 static const u16 rfseqA_init_gain[] = { 0x516f, 0x516f, 0x516f, 0x516f };
15506 u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f };15503 static const u16 rfseqA_init_gain_rev4[] = { 0x614f, 0x614f, 0x614f, 0x614f };
15507 u16 rfseqA_init_gain_rev4_elna[] = {15504 static const u16 rfseqA_init_gain_rev4_elna[] = {
15508 0x314f, 0x314f, 0x314f, 0x314f };15505 0x314f, 0x314f, 0x314f, 0x314f };
15509 u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f };15506 static const u16 rfseqA_init_gain_rev5[] = { 0x714f, 0x714f, 0x714f, 0x714f };
15510 u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f };15507 static const u16 rfseqA_init_gain_rev6[] = { 0x714f, 0x714f };
15511 u16 *rfseq_init_gain;15508 const u16 *rfseq_init_gain;
15512 u16 initG_gaincode = 0x627e;15509 u16 initG_gaincode = 0x627e;
15513 u16 initG_gaincode_rev4 = 0x527e;15510 u16 initG_gaincode_rev4 = 0x527e;
15514 u16 initG_gaincode_rev5 = 0x427e;15511 u16 initG_gaincode_rev5 = 0x427e;
@@ -15538,10 +15535,10 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) · 23 unmodified lines
15538 u16 clip1mdA_gaincode_rev6 = 0x2084;15535 u16 clip1mdA_gaincode_rev6 = 0x2084;
15539 u16 clip1md_gaincode = 0;15536 u16 clip1md_gaincode = 0;
15540 u16 clip1loG_gaincode = 0x0074;15537 u16 clip1loG_gaincode = 0x0074;
15541 u16 clip1loG_gaincode_rev5[] = {15538 static const u16 clip1loG_gaincode_rev5[] = {
15542 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c15539 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c
15543 };15540 };
15544 u16 clip1loG_gaincode_rev6[] = {15541 static const u16 clip1loG_gaincode_rev6[] = {
15545 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e15542 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e
15546 };15543 };
15547 u16 clip1loG_gaincode_rev6_224B0 = 0x1074;15544 u16 clip1loG_gaincode_rev6_224B0 = 0x1074;
@@ -16066,7 +16063,7 @@ static void wlc_phy_workarounds_nphy_gainctrl(struct brcms_phy *pi) · 518 unmodified lines
16066 16063
16067static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)16064static void wlc_phy_workarounds_nphy(struct brcms_phy *pi)
16068{16065{
16069 u8 rfseq_rx2tx_events[] = {16066 static const u8 rfseq_rx2tx_events[] = {
16070 NPHY_RFSEQ_CMD_NOP,16067 NPHY_RFSEQ_CMD_NOP,
16071 NPHY_RFSEQ_CMD_RXG_FBW,16068 NPHY_RFSEQ_CMD_RXG_FBW,
16072 NPHY_RFSEQ_CMD_TR_SWITCH,16069 NPHY_RFSEQ_CMD_TR_SWITCH,
@@ -16076,7 +16073,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 3 unmodified lines
16076 NPHY_RFSEQ_CMD_EXT_PA16073 NPHY_RFSEQ_CMD_EXT_PA
16077 };16074 };
16078 u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 };16075 u8 rfseq_rx2tx_dlys[] = { 8, 6, 6, 2, 4, 60, 1 };
16079 u8 rfseq_tx2rx_events[] = {16076 static const u8 rfseq_tx2rx_events[] = {
16080 NPHY_RFSEQ_CMD_NOP,16077 NPHY_RFSEQ_CMD_NOP,
16081 NPHY_RFSEQ_CMD_EXT_PA,16078 NPHY_RFSEQ_CMD_EXT_PA,
16082 NPHY_RFSEQ_CMD_TX_GAIN,16079 NPHY_RFSEQ_CMD_TX_GAIN,
@@ -16085,8 +16082,8 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 2 unmodified lines
16085 NPHY_RFSEQ_CMD_RXG_FBW,16082 NPHY_RFSEQ_CMD_RXG_FBW,
16086 NPHY_RFSEQ_CMD_CLR_HIQ_DIS16083 NPHY_RFSEQ_CMD_CLR_HIQ_DIS
16087 };16084 };
16088 u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };16085 static const u8 rfseq_tx2rx_dlys[] = { 8, 6, 2, 4, 4, 6, 1 };
16089 u8 rfseq_tx2rx_events_rev3[] = {16086 static const u8 rfseq_tx2rx_events_rev3[] = {
16090 NPHY_REV3_RFSEQ_CMD_EXT_PA,16087 NPHY_REV3_RFSEQ_CMD_EXT_PA,
16091 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,16088 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
16092 NPHY_REV3_RFSEQ_CMD_TX_GAIN,16089 NPHY_REV3_RFSEQ_CMD_TX_GAIN,
@@ -16096,7 +16093,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 3 unmodified lines
16096 NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,16093 NPHY_REV3_RFSEQ_CMD_CLR_HIQ_DIS,
16097 NPHY_REV3_RFSEQ_CMD_END16094 NPHY_REV3_RFSEQ_CMD_END
16098 };16095 };
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 };
16100 u8 rfseq_rx2tx_events_rev3[] = {16097 u8 rfseq_rx2tx_events_rev3[] = {
16101 NPHY_REV3_RFSEQ_CMD_NOP,16098 NPHY_REV3_RFSEQ_CMD_NOP,
16102 NPHY_REV3_RFSEQ_CMD_RXG_FBW,16099 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
@@ -16110,7 +16107,7 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 7 unmodified lines
16110 };16107 };
16111 u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 };16108 u8 rfseq_rx2tx_dlys_rev3[] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 };
16112 16109
16113 u8 rfseq_rx2tx_events_rev3_ipa[] = {16110 static const u8 rfseq_rx2tx_events_rev3_ipa[] = {
16114 NPHY_REV3_RFSEQ_CMD_NOP,16111 NPHY_REV3_RFSEQ_CMD_NOP,
16115 NPHY_REV3_RFSEQ_CMD_RXG_FBW,16112 NPHY_REV3_RFSEQ_CMD_RXG_FBW,
16116 NPHY_REV3_RFSEQ_CMD_TR_SWITCH,16113 NPHY_REV3_RFSEQ_CMD_TR_SWITCH,
@@ -16121,15 +16118,15 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 4 unmodified lines
16121 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,16118 NPHY_REV3_RFSEQ_CMD_INT_PA_PU,
16122 NPHY_REV3_RFSEQ_CMD_END16119 NPHY_REV3_RFSEQ_CMD_END
16123 };16120 };
16124 u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 };16121 static const u8 rfseq_rx2tx_dlys_rev3_ipa[] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 };
16125 u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };16122 static const u16 rfseq_rx2tx_dacbufpu_rev7[] = { 0x10f, 0x10f };
16126 16123
16127 s16 alpha0, alpha1, alpha2;16124 s16 alpha0, alpha1, alpha2;
16128 s16 beta0, beta1, beta2;16125 s16 beta0, beta1, beta2;
16129 u32 leg_data_weights, ht_data_weights, nss1_data_weights,16126 u32 leg_data_weights, ht_data_weights, nss1_data_weights,
16130 stbc_data_weights;16127 stbc_data_weights;
16131 u8 chan_freq_range = 0;16128 u8 chan_freq_range = 0;
16132 u16 dac_control = 0x0002;16129 static const u16 dac_control = 0x0002;
16133 u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 };16130 u16 aux_adc_vmid_rev7_core0[] = { 0x8e, 0x96, 0x96, 0x96 };
16134 u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 };16131 u16 aux_adc_vmid_rev7_core1[] = { 0x8f, 0x9f, 0x9f, 0x96 };
16135 u16 aux_adc_vmid_rev4[] = { 0xa2, 0xb4, 0xb4, 0x89 };16132 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
16139 u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 };16136 u16 aux_adc_gain_rev4[] = { 0x02, 0x02, 0x02, 0x00 };
16140 u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 };16137 u16 aux_adc_gain_rev3[] = { 0x02, 0x02, 0x02, 0x00 };
16141 u16 *aux_adc_gain;16138 u16 *aux_adc_gain;
16142 u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };16139 static const u16 sk_adc_vmid[] = { 0xb4, 0xb4, 0xb4, 0x24 };
16143 u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };16140 static const u16 sk_adc_gain[] = { 0x02, 0x02, 0x02, 0x02 };
16144 s32 min_nvar_val = 0x18d;16141 s32 min_nvar_val = 0x18d;
16145 s32 min_nvar_offset_6mbps = 20;16142 s32 min_nvar_offset_6mbps = 20;
16146 u8 pdetrange;16143 u8 pdetrange;
@@ -16151,9 +16148,9 @@ static void wlc_phy_workarounds_nphy(struct brcms_phy *pi) · 4 unmodified lines
16151 u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77;16148 u16 rfseq_rx2tx_lpf_h_hpc_rev7 = 0x77;
16152 u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77;16149 u16 rfseq_tx2rx_lpf_h_hpc_rev7 = 0x77;
16153 u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77;16150 u16 rfseq_pktgn_lpf_h_hpc_rev7 = 0x77;
16154 u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 };16151 static const u16 rfseq_htpktgn_lpf_hpc_rev7[] = { 0x77, 0x11, 0x11 };
16155 u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };16152 static const u16 rfseq_pktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16156 u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };16153 static const u16 rfseq_cckpktgn_lpf_hpc_rev7[] = { 0x11, 0x11 };
16157 u16 ipalvlshift_3p3_war_en = 0;16154 u16 ipalvlshift_3p3_war_en = 0;
16158 u16 rccal_bcap_val, rccal_scap_val;16155 u16 rccal_bcap_val, rccal_scap_val;
16159 u16 rccal_tx20_11b_bcap = 0;16156 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
24291 u16 bbmult;24288 u16 bbmult;
24292 u16 tblentry;24289 u16 tblentry;
24293 24290
24294 struct nphy_txiqcal_ladder ladder_lo[] = {24291 static const struct nphy_txiqcal_ladder ladder_lo[] = {
24295 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},24292 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
24296 {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5},24293 {25, 0}, {25, 1}, {25, 2}, {25, 3}, {25, 4}, {25, 5},
24297 {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7}24294 {25, 6}, {25, 7}, {35, 7}, {50, 7}, {71, 7}, {100, 7}
24298 };24295 };
24299 24296
24300 struct nphy_txiqcal_ladder ladder_iq[] = {24297 static const struct nphy_txiqcal_ladder ladder_iq[] = {
24301 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},24298 {3, 0}, {4, 0}, {6, 0}, {9, 0}, {13, 0}, {18, 0},
24302 {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1},24299 {25, 0}, {35, 0}, {50, 0}, {71, 0}, {100, 0}, {100, 1},
24303 {100, 2}, {100, 3}, {100, 4}, {100, 5}, {100, 6}, {100, 7}24300 {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
25773 u16 cal_gain[2];25770 u16 cal_gain[2];
25774 struct nphy_iqcal_params cal_params[2];25771 struct nphy_iqcal_params cal_params[2];
25775 u32 tbl_len;25772 u32 tbl_len;
25776 void *tbl_ptr;25773 const void *tbl_ptr;
25777 bool ladder_updated[2];25774 bool ladder_updated[2];
25778 u8 mphase_cal_lastphase = 0;25775 u8 mphase_cal_lastphase = 0;
25779 int bcmerror = 0;25776 int bcmerror = 0;
25780 bool phyhang_avoid_state = false;25777 bool phyhang_avoid_state = false;
25781 25778
25782 u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {25779 static const u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
25783 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901,25780 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901,
25784 0x1902,25781 0x1902,
25785 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607,25782 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607,
25786 0x640725783 0x6407
25787 };25784 };
25788 25785
25789 u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = {25786 static const u16 tbl_tx_iqlo_cal_iqimb_ladder_20[] = {
25790 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400,25787 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400,
25791 0x3200,25788 0x3200,
25792 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406,25789 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406,
25793 0x640725790 0x6407
25794 };25791 };
25795 25792
25796 u16 tbl_tx_iqlo_cal_loft_ladder_40[] = {25793 static const u16 tbl_tx_iqlo_cal_loft_ladder_40[] = {
25797 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201,25794 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201,
25798 0x1202,25795 0x1202,
25799 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207,25796 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207,
25800 0x470725797 0x4707
25801 };25798 };
25802 25799
25803 u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = {25800 static const u16 tbl_tx_iqlo_cal_iqimb_ladder_40[] = {
25804 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900,25801 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900,
25805 0x2300,25802 0x2300,
25806 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706,25803 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706,
25807 0x470725804 0x4707
25808 };25805 };
25809 25806
25810 u16 tbl_tx_iqlo_cal_startcoefs[] = {25807 static const u16 tbl_tx_iqlo_cal_startcoefs[] = {
25811 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,25808 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25812 0x000025809 0x0000
25813 };25810 };
25814 25811
25815 u16 tbl_tx_iqlo_cal_cmds_fullcal[] = {25812 static const u16 tbl_tx_iqlo_cal_cmds_fullcal[] = {
25816 0x8123, 0x8264, 0x8086, 0x8245, 0x8056,25813 0x8123, 0x8264, 0x8086, 0x8245, 0x8056,
25817 0x9123, 0x9264, 0x9086, 0x9245, 0x905625814 0x9123, 0x9264, 0x9086, 0x9245, 0x9056
25818 };25815 };
25819 25816
25820 u16 tbl_tx_iqlo_cal_cmds_recal[] = {25817 static const u16 tbl_tx_iqlo_cal_cmds_recal[] = {
25821 0x8101, 0x8253, 0x8053, 0x8234, 0x8034,25818 0x8101, 0x8253, 0x8053, 0x8234, 0x8034,
25822 0x9101, 0x9253, 0x9053, 0x9234, 0x903425819 0x9101, 0x9253, 0x9053, 0x9234, 0x9034
25823 };25820 };
25824 25821
25825 u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = {25822 static const u16 tbl_tx_iqlo_cal_startcoefs_nphyrev3[] = {
25826 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,25823 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25827 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,25824 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
25828 0x000025825 0x0000
25829 };25826 };
25830 25827
25831 u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = {25828 static const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = {
25832 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234,25829 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234,
25833 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x923425830 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234
25834 };25831 };
25835 25832
25836 u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = {25833 static const u16 tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = {
25837 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223,25834 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223,
25838 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x922325835 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223
25839 };25836 };
drivers/net/wireless/intel/iwlwifi/cfg/7000.c+1−0
@@ -309,6 +309,7 @@ const struct iwl_cfg iwl3168_2ac_cfg = { · 308 unmodified lines
309 .nvm_calib_ver = IWL3168_TX_POWER_VERSION,309 .nvm_calib_ver = IWL3168_TX_POWER_VERSION,
310 .pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,310 .pwr_tx_backoffs = iwl7265_pwr_tx_backoffs,
311 .dccm_len = IWL7265_DCCM_LEN,311 .dccm_len = IWL7265_DCCM_LEN,
312 .nvm_type = IWL_NVM_SDP,
312};313};
313 314
314const struct iwl_cfg iwl7265_2ac_cfg = {315const 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
164 .default_nvm_file_C_step = DEFAULT_NVM_FILE_FAMILY_8000C, \164 .default_nvm_file_C_step = DEFAULT_NVM_FILE_FAMILY_8000C, \
165 .thermal_params = &iwl8000_tt_params, \165 .thermal_params = &iwl8000_tt_params, \
166 .apmg_not_supported = true, \166 .apmg_not_supported = true, \
167 .ext_nvm = true, \167 .nvm_type = IWL_NVM_EXT, \
168 .dbgc_supported = true168 .dbgc_supported = true
169 169
170#define IWL_DEVICE_8000 \170#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
148 .vht_mu_mimo_supported = true, \148 .vht_mu_mimo_supported = true, \
149 .mac_addr_from_csr = true, \149 .mac_addr_from_csr = true, \
150 .rf_id = true, \150 .rf_id = true, \
151 .ext_nvm = true, \151 .nvm_type = IWL_NVM_EXT, \
152 .dbgc_supported = true152 .dbgc_supported = true
153 153
154const struct iwl_cfg iwl9160_2ac_cfg = {154const 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
133 .use_tfh = true, \133 .use_tfh = true, \
134 .rf_id = true, \134 .rf_id = true, \
135 .gen2 = true, \135 .gen2 = true, \
136 .ext_nvm = true, \136 .nvm_type = IWL_NVM_EXT, \
137 .dbgc_supported = true137 .dbgc_supported = true
138 138
139const struct iwl_cfg iwla000_2ac_cfg_hr = {139const 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
108 * @NVM_SECTION_TYPE_REGULATORY: regulatory section108 * @NVM_SECTION_TYPE_REGULATORY: regulatory section
109 * @NVM_SECTION_TYPE_CALIBRATION: calibration section109 * @NVM_SECTION_TYPE_CALIBRATION: calibration section
110 * @NVM_SECTION_TYPE_PRODUCTION: production section110 * @NVM_SECTION_TYPE_PRODUCTION: production section
111 * @NVM_SECTION_TYPE_REGULATORY_SDP: regulatory section used by 3168 series
111 * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section112 * @NVM_SECTION_TYPE_MAC_OVERRIDE: MAC override section
112 * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section113 * @NVM_SECTION_TYPE_PHY_SKU: PHY SKU section
113 * @NVM_MAX_NUM_SECTIONS: number of sections114 * @NVM_MAX_NUM_SECTIONS: number of sections
@@ -117,6 +118,7 @@ enum iwl_nvm_section_type { · 3 unmodified lines
117 NVM_SECTION_TYPE_REGULATORY = 3,118 NVM_SECTION_TYPE_REGULATORY = 3,
118 NVM_SECTION_TYPE_CALIBRATION = 4,119 NVM_SECTION_TYPE_CALIBRATION = 4,
119 NVM_SECTION_TYPE_PRODUCTION = 5,120 NVM_SECTION_TYPE_PRODUCTION = 5,
121 NVM_SECTION_TYPE_REGULATORY_SDP = 8,
120 NVM_SECTION_TYPE_MAC_OVERRIDE = 11,122 NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
121 NVM_SECTION_TYPE_PHY_SKU = 12,123 NVM_SECTION_TYPE_PHY_SKU = 12,
122 NVM_MAX_NUM_SECTIONS = 13,124 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
1086 1086
1087 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {1087 if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) {
1088 /* stop recording */1088 /* stop recording */
1089 iwl_set_bits_prph(fwrt->trans, MON_BUFF_SAMPLE_CTL, 0x100);1089 iwl_fw_dbg_stop_recording(fwrt);
1090 1090
1091 iwl_fw_error_dump(fwrt);1091 iwl_fw_error_dump(fwrt);
1092 1092
@@ -1104,10 +1104,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work) · 11 unmodified lines
1104 u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE);1104 u32 in_sample = iwl_read_prph(fwrt->trans, DBGC_IN_SAMPLE);
1105 u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL);1105 u32 out_ctrl = iwl_read_prph(fwrt->trans, DBGC_OUT_CTRL);
1106 1106
1107 /* stop recording */1107 iwl_fw_dbg_stop_recording(fwrt);
1108 iwl_write_prph(fwrt->trans, DBGC_IN_SAMPLE, 0);
1109 udelay(100);
1110 iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, 0);
1111 /* wait before we collect the data till the DBGC stop */1108 /* wait before we collect the data till the DBGC stop */
1112 udelay(500);1109 udelay(500);
1113 1110
drivers/net/wireless/intel/iwlwifi/fw/dbg.h+15−0
@@ -68,6 +68,8 @@ · 67 unmodified lines
68#include <linux/workqueue.h>68#include <linux/workqueue.h>
69#include <net/cfg80211.h>69#include <net/cfg80211.h>
70#include "runtime.h"70#include "runtime.h"
71#include "iwl-prph.h"
72#include "iwl-io.h"
71#include "file.h"73#include "file.h"
72#include "error-dump.h"74#include "error-dump.h"
73 75
@@ -194,8 +196,21 @@ _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt, · 120 unmodified lines
194 iwl_fw_dbg_get_trigger((fwrt)->fw,\196 iwl_fw_dbg_get_trigger((fwrt)->fw,\
195 (trig)))197 (trig)))
196 198
199static 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
197static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)210static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)
198{211{
212 iwl_fw_dbg_stop_recording(fwrt);
213
199 fwrt->dump.conf = FW_DBG_INVALID;214 fwrt->dump.conf = FW_DBG_INVALID;
200}215}
201 216
drivers/net/wireless/intel/iwlwifi/iwl-config.h+14−2
@@ -108,6 +108,18 @@ enum iwl_led_mode { · 107 unmodified lines
108 IWL_LED_DISABLE,108 IWL_LED_DISABLE,
109};109};
110 110
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 */
117enum iwl_nvm_type {
118 IWL_NVM,
119 IWL_NVM_EXT,
120 IWL_NVM_SDP,
121};
122
111/*123/*
112 * This is the threshold value of plcp error rate per 100mSecs. It is124 * This is the threshold value of plcp error rate per 100mSecs. It is
113 * used to set and check for the validity of plcp_delta.125 * used to set and check for the validity of plcp_delta.
@@ -320,7 +332,7 @@ struct iwl_pwr_tx_backoff { · 206 unmodified lines
320 * @integrated: discrete or integrated332 * @integrated: discrete or integrated
321 * @gen2: a000 and on transport operation333 * @gen2: a000 and on transport operation
322 * @cdb: CDB support334 * @cdb: CDB support
323 * @ext_nvm: extended NVM format335 * @nvm_type: see &enum iwl_nvm_type
324 *336 *
325 * We enable the driver to be backward compatible wrt. hardware features.337 * We enable the driver to be backward compatible wrt. hardware features.
326 * API differences in uCode shouldn't be handled here but through TLVs338 * API differences in uCode shouldn't be handled here but through TLVs
@@ -342,6 +354,7 @@ struct iwl_cfg { · 15 unmodified lines
342 const struct iwl_tt_params *thermal_params;354 const struct iwl_tt_params *thermal_params;
343 enum iwl_device_family device_family;355 enum iwl_device_family device_family;
344 enum iwl_led_mode led_mode;356 enum iwl_led_mode led_mode;
357 enum iwl_nvm_type nvm_type;
345 u32 max_data_size;358 u32 max_data_size;
346 u32 max_inst_size;359 u32 max_inst_size;
347 netdev_features_t features;360 netdev_features_t features;
@@ -369,7 +382,6 @@ struct iwl_cfg { · 21 unmodified lines
369 use_tfh:1,382 use_tfh:1,
370 gen2:1,383 gen2:1,
371 cdb:1,384 cdb:1,
372 ext_nvm:1,
373 dbgc_supported:1;385 dbgc_supported:1;
374 u8 valid_tx_ant;386 u8 valid_tx_ant;
375 u8 valid_rx_ant;387 u8 valid_rx_ant;
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c+62−75
@@ -77,7 +77,7 @@ · 76 unmodified lines
77#include "iwl-csr.h"77#include "iwl-csr.h"
78 78
79/* NVM offsets (in words) definitions */79/* NVM offsets (in words) definitions */
80enum wkp_nvm_offsets {80enum nvm_offsets {
81 /* NVM HW-Section offset (in words) definitions */81 /* NVM HW-Section offset (in words) definitions */
82 SUBSYSTEM_ID = 0x0A,82 SUBSYSTEM_ID = 0x0A,
83 HW_ADDR = 0x15,83 HW_ADDR = 0x15,
@@ -92,7 +92,10 @@ enum wkp_nvm_offsets { · 8 unmodified lines
92 92
93 /* NVM calibration section offset (in words) definitions */93 /* NVM calibration section offset (in words) definitions */
94 NVM_CALIB_SECTION = 0x2B8,94 NVM_CALIB_SECTION = 0x2B8,
95 XTAL_CALIB = 0x316 - NVM_CALIB_SECTION95 XTAL_CALIB = 0x316 - NVM_CALIB_SECTION,
96
97 /* NVM REGULATORY -Section offset (in words) definitions */
98 NVM_CHANNELS_SDP = 0,
96};99};
97 100
98enum ext_nvm_offsets {101enum ext_nvm_offsets {
@@ -206,8 +209,36 @@ enum iwl_nvm_channel_flags { · 107 unmodified lines
206 NVM_CHANNEL_DC_HIGH = BIT(12),209 NVM_CHANNEL_DC_HIGH = BIT(12),
207};210};
208 211
212static inline void iwl_nvm_print_channel_flags(struct device *dev, u32 level,
213 int chan, u16 flags)
214{
209#define CHECK_AND_PRINT_I(x) \215#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}
211 242
212static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,243static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,
213 u16 nvm_flags, const struct iwl_cfg *cfg)244 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
215 u32 flags = IEEE80211_CHAN_NO_HT40;246 u32 flags = IEEE80211_CHAN_NO_HT40;
216 u32 last_5ghz_ht = LAST_5GHZ_HT;247 u32 last_5ghz_ht = LAST_5GHZ_HT;
217 248
218 if (cfg->ext_nvm)249 if (cfg->nvm_type == IWL_NVM_EXT)
219 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;250 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
220 251
221 if (!is_5ghz && (nvm_flags & NVM_CHANNEL_40MHZ)) {252 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
268 int num_of_ch, num_2ghz_channels;299 int num_of_ch, num_2ghz_channels;
269 const u8 *nvm_chan;300 const u8 *nvm_chan;
270 301
271 if (!cfg->ext_nvm) {302 if (cfg->nvm_type != IWL_NVM_EXT) {
272 num_of_ch = IWL_NUM_CHANNELS;303 num_of_ch = IWL_NUM_CHANNELS;
273 nvm_chan = &iwl_nvm_channels[0];304 nvm_chan = &iwl_nvm_channels[0];
274 num_2ghz_channels = NUM_2GHZ_CHANNELS;305 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
302 * supported, hence we still want to add them to333 * supported, hence we still want to add them to
303 * the list of supported channels to cfg80211.334 * the list of supported channels to cfg80211.
304 */335 */
305 IWL_DEBUG_EEPROM(dev,336 iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
306 "Ch. %d Flags %x [%sGHz] - No traffic\n",337 nvm_chan[ch_idx], ch_flags);
307 nvm_chan[ch_idx],
308 ch_flags,
309 (ch_idx >= num_2ghz_channels) ?
310 "5.2" : "2.4");
311 continue;338 continue;
312 }339 }
313 340
@@ -337,27 +364,10 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg, · 23 unmodified lines
337 else364 else
338 channel->flags = 0;365 channel->flags = 0;
339 366
340 IWL_DEBUG_EEPROM(dev,367 iwl_nvm_print_channel_flags(dev, IWL_DL_EEPROM,
341 "Ch. %d [%sGHz] flags 0x%x %s%s%s%s%s%s%s%s%s%s%s%s(%ddBm): Ad-Hoc %ssupported\n",368 channel->hw_value, ch_flags);
342 channel->hw_value,369 IWL_DEBUG_EEPROM(dev, "Ch. %d: %ddBm\n",
343 is_5ghz ? "5.2" : "2.4",370 channel->hw_value, channel->max_power);
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 ");
361 }371 }
362 372
363 return n_channels;373 return n_channels;
@@ -484,7 +494,7 @@ IWL_EXPORT_SYMBOL(iwl_init_sbands); · 120 unmodified lines
484static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,494static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
485 const __le16 *phy_sku)495 const __le16 *phy_sku)
486{496{
487 if (!cfg->ext_nvm)497 if (cfg->nvm_type != IWL_NVM_EXT)
488 return le16_to_cpup(nvm_sw + SKU);498 return le16_to_cpup(nvm_sw + SKU);
489 499
490 return le32_to_cpup((__le32 *)(phy_sku + SKU_FAMILY_8000));500 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
492 502
493static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw)503static int iwl_get_nvm_version(const struct iwl_cfg *cfg, const __le16 *nvm_sw)
494{504{
495 if (!cfg->ext_nvm)505 if (cfg->nvm_type != IWL_NVM_EXT)
496 return le16_to_cpup(nvm_sw + NVM_VERSION);506 return le16_to_cpup(nvm_sw + NVM_VERSION);
497 else507 else
498 return le32_to_cpup((__le32 *)(nvm_sw +508 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
502static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw,512static int iwl_get_radio_cfg(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
503 const __le16 *phy_sku)513 const __le16 *phy_sku)
504{514{
505 if (!cfg->ext_nvm)515 if (cfg->nvm_type != IWL_NVM_EXT)
506 return le16_to_cpup(nvm_sw + RADIO_CFG);516 return le16_to_cpup(nvm_sw + RADIO_CFG);
507 517
508 return le32_to_cpup((__le32 *)(phy_sku + RADIO_CFG_FAMILY_EXT_NVM));518 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
513{523{
514 int n_hw_addr;524 int n_hw_addr;
515 525
516 if (!cfg->ext_nvm)526 if (cfg->nvm_type != IWL_NVM_EXT)
517 return le16_to_cpup(nvm_sw + N_HW_ADDRS);527 return le16_to_cpup(nvm_sw + N_HW_ADDRS);
518 528
519 n_hw_addr = le32_to_cpup((__le32 *)(nvm_sw + N_HW_ADDRS_FAMILY_8000));529 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
525 struct iwl_nvm_data *data,535 struct iwl_nvm_data *data,
526 u32 radio_cfg)536 u32 radio_cfg)
527{537{
528 if (!cfg->ext_nvm) {538 if (cfg->nvm_type != IWL_NVM_EXT) {
529 data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg);539 data->radio_cfg_type = NVM_RF_CFG_TYPE_MSK(radio_cfg);
530 data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg);540 data->radio_cfg_step = NVM_RF_CFG_STEP_MSK(radio_cfg);
531 data->radio_cfg_dash = NVM_RF_CFG_DASH_MSK(radio_cfg);541 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
634{644{
635 if (cfg->mac_addr_from_csr) {645 if (cfg->mac_addr_from_csr) {
636 iwl_set_hw_address_from_csr(trans, data);646 iwl_set_hw_address_from_csr(trans, data);
637 } else if (!cfg->ext_nvm) {647 } else if (cfg->nvm_type != IWL_NVM_EXT) {
638 const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR);648 const u8 *hw_addr = (const u8 *)(nvm_hw + HW_ADDR);
639 649
640 /* The byte order is little endian 16 bit, meaning 214365 */650 /* 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
706 u16 lar_config;716 u16 lar_config;
707 const __le16 *ch_section;717 const __le16 *ch_section;
708 718
709 if (!cfg->ext_nvm)719 if (cfg->nvm_type != IWL_NVM_EXT)
710 data = kzalloc(sizeof(*data) +720 data = kzalloc(sizeof(*data) +
711 sizeof(struct ieee80211_channel) *721 sizeof(struct ieee80211_channel) *
712 IWL_NUM_CHANNELS,722 IWL_NUM_CHANNELS,
@@ -740,7 +750,7 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 27 unmodified lines
740 750
741 data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw);751 data->n_hw_addrs = iwl_get_n_hw_addrs(cfg, nvm_sw);
742 752
743 if (!cfg->ext_nvm) {753 if (cfg->nvm_type != IWL_NVM_EXT) {
744 /* Checking for required sections */754 /* Checking for required sections */
745 if (!nvm_calib) {755 if (!nvm_calib) {
746 IWL_ERR(trans,756 IWL_ERR(trans,
@@ -748,11 +758,15 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, · 1 unmodified line
748 kfree(data);758 kfree(data);
749 return NULL;759 return NULL;
750 }760 }
761
762 ch_section = cfg->nvm_type == IWL_NVM_SDP ?
763 &regulatory[NVM_CHANNELS_SDP] :
764 &nvm_sw[NVM_CHANNELS];
765
751 /* in family 8000 Xtal calibration values moved to OTP */766 /* in family 8000 Xtal calibration values moved to OTP */
752 data->xtal_calib[0] = *(nvm_calib + XTAL_CALIB);767 data->xtal_calib[0] = *(nvm_calib + XTAL_CALIB);
753 data->xtal_calib[1] = *(nvm_calib + XTAL_CALIB + 1);768 data->xtal_calib[1] = *(nvm_calib + XTAL_CALIB + 1);
754 lar_enabled = true;769 lar_enabled = true;
755 ch_section = &nvm_sw[NVM_CHANNELS];
756 } else {770 } else {
757 u16 lar_offset = data->nvm_version < 0xE39 ?771 u16 lar_offset = data->nvm_version < 0xE39 ?
758 NVM_LAR_OFFSET_OLD :772 NVM_LAR_OFFSET_OLD :
@@ -786,7 +800,7 @@ static u32 iwl_nvm_get_regdom_bw_flags(const u8 *nvm_chan, · 27 unmodified lines
786 u32 flags = NL80211_RRF_NO_HT40;800 u32 flags = NL80211_RRF_NO_HT40;
787 u32 last_5ghz_ht = LAST_5GHZ_HT;801 u32 last_5ghz_ht = LAST_5GHZ_HT;
788 802
789 if (cfg->ext_nvm)803 if (cfg->nvm_type == IWL_NVM_EXT)
790 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;804 last_5ghz_ht = LAST_5GHZ_HT_FAMILY_8000;
791 805
792 if (ch_idx < NUM_2GHZ_CHANNELS &&806 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
834 int ch_idx;848 int ch_idx;
835 u16 ch_flags;849 u16 ch_flags;
836 u32 reg_rule_flags, prev_reg_rule_flags = 0;850 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 ?
838 iwl_ext_nvm_channels : iwl_nvm_channels;852 iwl_ext_nvm_channels : iwl_nvm_channels;
839 struct ieee80211_regdomain *regd;853 struct ieee80211_regdomain *regd;
840 int size_of_regd;854 int size_of_regd;
@@ -843,7 +857,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 2 unmodified lines
843 int center_freq, prev_center_freq = 0;857 int center_freq, prev_center_freq = 0;
844 int valid_rules = 0;858 int valid_rules = 0;
845 bool new_rule;859 bool new_rule;
846 int max_num_ch = cfg->ext_nvm ?860 int max_num_ch = cfg->nvm_type == IWL_NVM_EXT ?
847 IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS;861 IWL_NUM_CHANNELS_EXT : IWL_NUM_CHANNELS;
848 862
849 if (WARN_ON_ONCE(num_of_ch > NL80211_MAX_SUPP_REG_RULES))863 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
873 new_rule = false;887 new_rule = false;
874 888
875 if (!(ch_flags & NVM_CHANNEL_VALID)) {889 if (!(ch_flags & NVM_CHANNEL_VALID)) {
876 IWL_DEBUG_DEV(dev, IWL_DL_LAR,890 iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
877 "Ch. %d Flags %x [%sGHz] - No traffic\n",891 nvm_chan[ch_idx], ch_flags);
878 nvm_chan[ch_idx],
879 ch_flags,
880 (ch_idx >= NUM_2GHZ_CHANNELS) ?
881 "5.2" : "2.4");
882 continue;892 continue;
883 }893 }
884 894
@@ -914,31 +924,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, · 29 unmodified lines
914 prev_center_freq = center_freq;924 prev_center_freq = center_freq;
915 prev_reg_rule_flags = reg_rule_flags;925 prev_reg_rule_flags = reg_rule_flags;
916 926
917 IWL_DEBUG_DEV(dev, IWL_DL_LAR,927 iwl_nvm_print_channel_flags(dev, IWL_DL_LAR,
918 "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s%s%s%s(0x%02x)\n",928 nvm_chan[ch_idx], ch_flags);
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" : "");
942 }929 }
943 930
944 regd->n_reg_rules = valid_rules;931 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
1077 mvm->vif_count = 0;1077 mvm->vif_count = 0;
1078 mvm->rx_ba_sessions = 0;1078 mvm->rx_ba_sessions = 0;
1079 mvm->fwrt.dump.conf = FW_DBG_INVALID;1079 mvm->fwrt.dump.conf = FW_DBG_INVALID;
1080 mvm->monitor_on = false;
1080 1081
1081 /* keep statistics ticking */1082 /* keep statistics ticking */
1082 iwl_mvm_accu_radio_stats(mvm);1083 iwl_mvm_accu_radio_stats(mvm);
@@ -1437,6 +1438,9 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, · 354 unmodified lines
1437 mvm->p2p_device_vif = vif;1438 mvm->p2p_device_vif = vif;
1438 }1439 }
1439 1440
1441 if (vif->type == NL80211_IFTYPE_MONITOR)
1442 mvm->monitor_on = true;
1443
1440 iwl_mvm_vif_dbgfs_register(mvm, vif);1444 iwl_mvm_vif_dbgfs_register(mvm, vif);
1441 goto out_unlock;1445 goto out_unlock;
1442 1446
@@ -1526,6 +1530,9 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, · 83 unmodified lines
1526 iwl_mvm_power_update_mac(mvm);1530 iwl_mvm_power_update_mac(mvm);
1527 iwl_mvm_mac_ctxt_remove(mvm, vif);1531 iwl_mvm_mac_ctxt_remove(mvm, vif);
1528 1532
1533 if (vif->type == NL80211_IFTYPE_MONITOR)
1534 mvm->monitor_on = false;
1535
1529out_release:1536out_release:
1530 mutex_unlock(&mvm->mutex);1537 mutex_unlock(&mvm->mutex);
1531}1538}
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h+4−1
@@ -1015,6 +1015,9 @@ struct iwl_mvm { · 1014 unmodified lines
1015 bool drop_bcn_ap_mode;1015 bool drop_bcn_ap_mode;
1016 1016
1017 struct delayed_work cs_tx_unblock_dwork;1017 struct delayed_work cs_tx_unblock_dwork;
1018
1019 /* does a monitor vif exist (only one can exist hence bool) */
1020 bool monitor_on;
1018#ifdef CONFIG_ACPI1021#ifdef CONFIG_ACPI
1019 struct iwl_mvm_sar_profile sar_profiles[IWL_MVM_SAR_PROFILE_NUM];1022 struct iwl_mvm_sar_profile sar_profiles[IWL_MVM_SAR_PROFILE_NUM];
1020 struct iwl_mvm_geo_profile geo_profiles[IWL_NUM_GEO_PROFILES];1023 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
1159 * Enable LAR only if it is supported by the FW (TLV) &&1162 * Enable LAR only if it is supported by the FW (TLV) &&
1160 * enabled in the NVM1163 * enabled in the NVM
1161 */1164 */
1162 if (mvm->cfg->ext_nvm)1165 if (mvm->cfg->nvm_type == IWL_NVM_EXT)
1163 return nvm_lar && tlv_lar;1166 return nvm_lar && tlv_lar;
1164 else1167 else
1165 return tlv_lar;1168 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
295 const __be16 *hw;295 const __be16 *hw;
296 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;296 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;
297 bool lar_enabled;297 bool lar_enabled;
298 int regulatory_type;
298 299
299 /* Checking for required sections */300 /* Checking for required sections */
300 if (!mvm->trans->cfg->ext_nvm) {301 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
301 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||302 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||
302 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) {303 !mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data) {
303 IWL_ERR(mvm, "Can't parse empty OTP/NVM sections\n");304 IWL_ERR(mvm, "Can't parse empty OTP/NVM sections\n");
304 return NULL;305 return NULL;
305 }306 }
306 } else {307 } 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
307 /* SW and REGULATORY sections are mandatory */313 /* SW and REGULATORY sections are mandatory */
308 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data ||314 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) {
310 IWL_ERR(mvm,316 IWL_ERR(mvm,
311 "Can't parse empty family 8000 OTP/NVM sections\n");317 "Can't parse empty family 8000 OTP/NVM sections\n");
312 return NULL;318 return NULL;
@@ -330,11 +336,14 @@ iwl_parse_nvm_sections(struct iwl_mvm *mvm) · 17 unmodified lines
330 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data;336 hw = (const __be16 *)sections[mvm->cfg->nvm_hw_section_num].data;
331 sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data;337 sw = (const __le16 *)sections[NVM_SECTION_TYPE_SW].data;
332 calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data;338 calib = (const __le16 *)sections[NVM_SECTION_TYPE_CALIBRATION].data;
333 regulatory = (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
334 mac_override =339 mac_override =
335 (const __le16 *)sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data;340 (const __le16 *)sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data;
336 phy_sku = (const __le16 *)sections[NVM_SECTION_TYPE_PHY_SKU].data;341 phy_sku = (const __le16 *)sections[NVM_SECTION_TYPE_PHY_SKU].data;
337 342
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
338 lar_enabled = !iwlwifi_mod_params.lar_disable &&347 lar_enabled = !iwlwifi_mod_params.lar_disable &&
339 fw_has_capa(&mvm->fw->ucode_capa,348 fw_has_capa(&mvm->fw->ucode_capa,
340 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);349 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
@@ -394,7 +403,7 @@ int iwl_mvm_read_external_nvm(struct iwl_mvm *mvm) · 53 unmodified lines
394 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n");403 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from external NVM\n");
395 404
396 /* Maximal size depends on NVM version */405 /* Maximal size depends on NVM version */
397 if (!mvm->trans->cfg->ext_nvm)406 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT)
398 max_section_size = IWL_MAX_NVM_SECTION_SIZE;407 max_section_size = IWL_MAX_NVM_SECTION_SIZE;
399 else408 else
400 max_section_size = IWL_MAX_EXT_NVM_SECTION_SIZE;409 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
465 break;474 break;
466 }475 }
467 476
468 if (!mvm->trans->cfg->ext_nvm) {477 if (mvm->trans->cfg->nvm_type != IWL_NVM_EXT) {
469 section_size =478 section_size =
470 2 * NVM_WORD1_LEN(le16_to_cpu(file_sec->word1));479 2 * NVM_WORD1_LEN(le16_to_cpu(file_sec->word1));
471 section_id = NVM_WORD2_ID(le16_to_cpu(file_sec->word2));480 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
740 struct ieee80211_regdomain *regd;749 struct ieee80211_regdomain *regd;
741 char mcc[3];750 char mcc[3];
742 751
743 if (mvm->cfg->ext_nvm) {752 if (mvm->cfg->nvm_type == IWL_NVM_EXT) {
744 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,753 tlv_lar = fw_has_capa(&mvm->fw->ucode_capa,
745 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);754 IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
746 nvm_lar = mvm->nvm_data->lar_enabled;755 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
244 return 0;244 return 0;
245 245
246 default:246 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);
248 }250 }
249 251
250 return 0;252 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
277 stats->flag |= RX_FLAG_DECRYPTED;277 stats->flag |= RX_FLAG_DECRYPTED;
278 return 0;278 return 0;
279 default:279 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);
281 }283 }
282 284
283 return 0;285 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
631 631
632 if (!iwl_mvm_firmware_running(mvm) ||632 if (!iwl_mvm_firmware_running(mvm) ||
633 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {633 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
634 ret = -EIO;634 ret = -ENODATA;
635 goto out;635 goto out;
636 }636 }
637 637
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
1122 }1122 }
1123 if (0 == tmp) {1123 if (0 == tmp) {
1124 read_addr = REG_DBI_RDATA + addr % 4;1124 read_addr = REG_DBI_RDATA + addr % 4;
1125 ret = rtl_read_byte(rtlpriv, read_addr);1125 ret = rtl_read_word(rtlpriv, read_addr);
1126 }1126 }
1127 return ret;1127 return ret;
1128}1128}
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
44 return -EINVAL;44 return -EINVAL;
45}45}
46 46
47static void of_mdiobus_register_phy(struct mii_bus *mdio,47static int of_mdiobus_register_phy(struct mii_bus *mdio,
48 struct device_node *child, u32 addr)48 struct device_node *child, u32 addr)
49{49{
50 struct phy_device *phy;50 struct phy_device *phy;
@@ -60,9 +60,13 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio, · 9 unmodified lines
60 else60 else
61 phy = get_phy_device(mdio, addr, is_c45);61 phy = get_phy_device(mdio, addr, is_c45);
62 if (IS_ERR(phy))62 if (IS_ERR(phy))
63 return;63 return PTR_ERR(phy);
64 64
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 }
66 if (rc > 0) {70 if (rc > 0) {
67 phy->irq = rc;71 phy->irq = rc;
68 mdio->irq[addr] = rc;72 mdio->irq[addr] = rc;
@@ -84,22 +88,23 @@ static void of_mdiobus_register_phy(struct mii_bus *mdio, · 15 unmodified lines
84 if (rc) {88 if (rc) {
85 phy_device_free(phy);89 phy_device_free(phy);
86 of_node_put(child);90 of_node_put(child);
87 return;91 return rc;
88 }92 }
89 93
90 dev_dbg(&mdio->dev, "registered phy %s at address %i\n",94 dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
91 child->name, addr);95 child->name, addr);
96 return 0;
92}97}
93 98
94static void of_mdiobus_register_device(struct mii_bus *mdio,99static int of_mdiobus_register_device(struct mii_bus *mdio,
95 struct device_node *child, u32 addr)100 struct device_node *child, u32 addr)
96{101{
97 struct mdio_device *mdiodev;102 struct mdio_device *mdiodev;
98 int rc;103 int rc;
99 104
100 mdiodev = mdio_device_create(mdio, addr);105 mdiodev = mdio_device_create(mdio, addr);
101 if (IS_ERR(mdiodev))106 if (IS_ERR(mdiodev))
102 return;107 return PTR_ERR(mdiodev);
103 108
104 /* Associate the OF node with the device structure so it109 /* Associate the OF node with the device structure so it
105 * can be looked up later.110 * can be looked up later.
@@ -112,11 +117,12 @@ static void of_mdiobus_register_device(struct mii_bus *mdio, · 6 unmodified lines
112 if (rc) {117 if (rc) {
113 mdio_device_free(mdiodev);118 mdio_device_free(mdiodev);
114 of_node_put(child);119 of_node_put(child);
115 return;120 return rc;
116 }121 }
117 122
118 dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n",123 dev_dbg(&mdio->dev, "registered mdio device %s at address %i\n",
119 child->name, addr);124 child->name, addr);
125 return 0;
120}126}
121 127
122/* The following is a list of PHY compatible strings which appear in128/* 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
219 }225 }
220 226
221 if (of_mdiobus_child_is_phy(child))227 if (of_mdiobus_child_is_phy(child))
222 of_mdiobus_register_phy(mdio, child, addr);228 rc = of_mdiobus_register_phy(mdio, child, addr);
223 else229 else
224 of_mdiobus_register_device(mdio, child, addr);230 rc = of_mdiobus_register_device(mdio, child, addr);
231 if (rc)
232 goto unregister;
225 }233 }
226 234
227 if (!scanphys)235 if (!scanphys)
@@ -242,12 +250,19 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) · 14 unmodified lines
242 dev_info(&mdio->dev, "scan phy %s at address %i\n",250 dev_info(&mdio->dev, "scan phy %s at address %i\n",
243 child->name, addr);251 child->name, addr);
244 252
245 if (of_mdiobus_child_is_phy(child))253 if (of_mdiobus_child_is_phy(child)) {
246 of_mdiobus_register_phy(mdio, child, addr);254 rc = of_mdiobus_register_phy(mdio, child, addr);
255 if (rc)
256 goto unregister;
257 }
247 }258 }
248 }259 }
249 260
250 return 0;261 return 0;
262
263unregister:
264 mdiobus_unregister(mdio);
265 return rc;
251}266}
252EXPORT_SYMBOL(of_mdiobus_register);267EXPORT_SYMBOL(of_mdiobus_register);
253 268
include/linux/filter.h+1−1
@@ -728,7 +728,7 @@ void xdp_do_flush_map(void); · 727 unmodified lines
728void bpf_warn_invalid_xdp_action(u32 act);728void bpf_warn_invalid_xdp_action(u32 act);
729void bpf_warn_invalid_xdp_redirect(u32 ifindex);729void bpf_warn_invalid_xdp_redirect(u32 ifindex);
730 730
731struct sock *do_sk_redirect_map(void);731struct sock *do_sk_redirect_map(struct sk_buff *skb);
732 732
733#ifdef CONFIG_BPF_JIT733#ifdef CONFIG_BPF_JIT
734extern int bpf_jit_enable;734extern 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
3694 unsigned char name_assign_type,3694 unsigned char name_assign_type,
3695 void (*setup)(struct net_device *),3695 void (*setup)(struct net_device *),
3696 unsigned int txqs, unsigned int rxqs);3696 unsigned int txqs, unsigned int rxqs);
3697int dev_get_valid_name(struct net *net, struct net_device *dev,
3698 const char *name);
3699
3697#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \3700#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
3698 alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)3701 alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)
3699 3702
include/net/inet_sock.h+1−1
@@ -96,7 +96,7 @@ struct inet_request_sock { · 95 unmodified lines
96 kmemcheck_bitfield_end(flags);96 kmemcheck_bitfield_end(flags);
97 u32 ir_mark;97 u32 ir_mark;
98 union {98 union {
99 struct ip_options_rcu *opt;99 struct ip_options_rcu __rcu *ireq_opt;
100#if IS_ENABLED(CONFIG_IPV6)100#if IS_ENABLED(CONFIG_IPV6)
101 struct {101 struct {
102 struct ipv6_txoptions *ipv6_opt;102 struct ipv6_txoptions *ipv6_opt;
include/net/tcp.h+5−0
@@ -840,6 +840,11 @@ struct tcp_skb_cb { · 839 unmodified lines
840 struct inet6_skb_parm h6;840 struct inet6_skb_parm h6;
841#endif841#endif
842 } header; /* For incoming skbs */842 } header; /* For incoming skbs */
843 struct {
844 __u32 key;
845 __u32 flags;
846 struct bpf_map *map;
847 } bpf;
843 };848 };
844};849};
845 850
kernel/bpf/arraymap.c+1−1
@@ -98,7 +98,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) · 97 unmodified lines
98 array_size += (u64) attr->max_entries * elem_size * num_possible_cpus();98 array_size += (u64) attr->max_entries * elem_size * num_possible_cpus();
99 99
100 if (array_size >= U32_MAX - PAGE_SIZE ||100 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)) {
102 bpf_map_area_free(array);102 bpf_map_area_free(array);
103 return ERR_PTR(-ENOMEM);103 return ERR_PTR(-ENOMEM);
104 }104 }
kernel/bpf/devmap.c+7−3
@@ -69,7 +69,7 @@ static LIST_HEAD(dev_map_list); · 68 unmodified lines
69 69
70static u64 dev_map_bitmap_size(const union bpf_attr *attr)70static u64 dev_map_bitmap_size(const union bpf_attr *attr)
71{71{
72 return BITS_TO_LONGS(attr->max_entries) * sizeof(unsigned long);72 return BITS_TO_LONGS((u64) attr->max_entries) * sizeof(unsigned long);
73}73}
74 74
75static struct bpf_map *dev_map_alloc(union bpf_attr *attr)75static 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
78 int err = -EINVAL;78 int err = -EINVAL;
79 u64 cost;79 u64 cost;
80 80
81 if (!capable(CAP_NET_ADMIN))
82 return ERR_PTR(-EPERM);
83
81 /* check sanity of attributes */84 /* check sanity of attributes */
82 if (attr->max_entries == 0 || attr->key_size != 4 ||85 if (attr->max_entries == 0 || attr->key_size != 4 ||
83 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)86 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
111 err = -ENOMEM;114 err = -ENOMEM;
112 115
113 /* A per cpu bitfield with a bit per possible net device */116 /* A per cpu bitfield with a bit per possible net device */
114 dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),117 dtab->flush_needed = __alloc_percpu_gfp(dev_map_bitmap_size(attr),
115 __alignof__(unsigned long));118 __alignof__(unsigned long),
119 GFP_KERNEL | __GFP_NOWARN);
116 if (!dtab->flush_needed)120 if (!dtab->flush_needed)
117 goto free_dtab;121 goto free_dtab;
118 122
kernel/bpf/hashtab.c+0−4
@@ -317,10 +317,6 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) · 316 unmodified lines
317 */317 */
318 goto free_htab;318 goto free_htab;
319 319
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
324 htab->elem_size = sizeof(struct htab_elem) +320 htab->elem_size = sizeof(struct htab_elem) +
325 round_up(htab->map.key_size, 8);321 round_up(htab->map.key_size, 8);
326 if (percpu)322 if (percpu)
kernel/bpf/sockmap.c+18−10
@@ -39,6 +39,7 @@ · 38 unmodified lines
39#include <linux/workqueue.h>39#include <linux/workqueue.h>
40#include <linux/list.h>40#include <linux/list.h>
41#include <net/strparser.h>41#include <net/strparser.h>
42#include <net/tcp.h>
42 43
43struct bpf_stab {44struct bpf_stab {
44 struct bpf_map map;45 struct bpf_map map;
@@ -101,9 +102,16 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb) · 56 unmodified lines
101 return SK_DROP;102 return SK_DROP;
102 103
103 skb_orphan(skb);104 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;
104 skb->sk = psock->sock;110 skb->sk = psock->sock;
105 bpf_compute_data_end(skb);111 bpf_compute_data_end(skb);
112 preempt_disable();
106 rc = (*prog->bpf_func)(skb, prog->insnsi);113 rc = (*prog->bpf_func)(skb, prog->insnsi);
114 preempt_enable();
107 skb->sk = NULL;115 skb->sk = NULL;
108 116
109 return rc;117 return rc;
@@ -114,17 +122,10 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) · 4 unmodified lines
114 struct sock *sk;122 struct sock *sk;
115 int rc;123 int rc;
116 124
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();
123 rc = smap_verdict_func(psock, skb);125 rc = smap_verdict_func(psock, skb);
124 switch (rc) {126 switch (rc) {
125 case SK_REDIRECT:127 case SK_REDIRECT:
126 sk = do_sk_redirect_map();128 sk = do_sk_redirect_map(skb);
127 preempt_enable();
128 if (likely(sk)) {129 if (likely(sk)) {
129 struct smap_psock *peer = smap_psock_sk(sk);130 struct smap_psock *peer = smap_psock_sk(sk);
130 131
@@ -141,8 +142,6 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) · 10 unmodified lines
141 /* Fall through and free skb otherwise */142 /* Fall through and free skb otherwise */
142 case SK_DROP:143 case SK_DROP:
143 default:144 default:
144 if (rc != SK_REDIRECT)
145 preempt_enable();
146 kfree_skb(skb);145 kfree_skb(skb);
147 }146 }
148}147}
@@ -487,6 +486,9 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr) · 338 unmodified lines
487 int err = -EINVAL;486 int err = -EINVAL;
488 u64 cost;487 u64 cost;
489 488
489 if (!capable(CAP_NET_ADMIN))
490 return ERR_PTR(-EPERM);
491
490 /* check sanity of attributes */492 /* check sanity of attributes */
491 if (attr->max_entries == 0 || attr->key_size != 4 ||493 if (attr->max_entries == 0 || attr->key_size != 4 ||
492 attr->value_size != 4 || attr->map_flags & ~BPF_F_NUMA_NODE)494 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
840 return -EINVAL;842 return -EINVAL;
841 }843 }
842 844
845 if (skops.sk->sk_type != SOCK_STREAM ||
846 skops.sk->sk_protocol != IPPROTO_TCP) {
847 fput(socket->file);
848 return -EOPNOTSUPP;
849 }
850
843 err = sock_map_ctx_update_elem(&skops, map, key, flags);851 err = sock_map_ctx_update_elem(&skops, map, key, flags);
844 fput(socket->file);852 fput(socket->file);
845 return err;853 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
1116 /* ctx accesses must be at a fixed offset, so that we can1116 /* ctx accesses must be at a fixed offset, so that we can
1117 * determine what type of data were returned.1117 * determine what type of data were returned.
1118 */1118 */
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) {
1120 char tn_buf[48];1125 char tn_buf[48];
1121 1126
1122 tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);1127 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
1124 tn_buf, off, size);1129 tn_buf, off, size);
1125 return -EACCES;1130 return -EACCES;
1126 }1131 }
1127 off += reg->var_off.value;
1128 err = check_ctx_access(env, insn_idx, off, size, t, &reg_type);1132 err = check_ctx_access(env, insn_idx, off, size, t, &reg_type);
1129 if (!err && t == BPF_READ && value_regno >= 0) {1133 if (!err && t == BPF_READ && value_regno >= 0) {
1130 /* ctx access returns either a scalar, or a1134 /* 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
2426}2430}
2427 2431
2428static void find_good_pkt_pointers(struct bpf_verifier_state *state,2432static 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)
2430{2435{
2431 struct bpf_reg_state *regs = state->regs, *reg;2436 struct bpf_reg_state *regs = state->regs, *reg;
2437 u16 new_range;
2432 int i;2438 int i;
2433 2439
2434 if (dst_reg->off < 0)2440 if (dst_reg->off < 0 ||
2441 (dst_reg->off == 0 && range_right_open))
2435 /* This doesn't give us any range */2442 /* This doesn't give us any range */
2436 return;2443 return;
2437 2444
@@ -2442,9 +2449,13 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 4 unmodified lines
2442 */2449 */
2443 return;2450 return;
2444 2451
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:
2446 *2457 *
2447 * Type 1/2:2458 * pkt_data in dst register:
2448 *2459 *
2449 * r2 = r3;2460 * r2 = r3;
2450 * r2 += 8;2461 * r2 += 8;
@@ -2461,7 +2472,7 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 10 unmodified lines
2461 * r2=pkt(id=n,off=8,r=0)2472 * r2=pkt(id=n,off=8,r=0)
2462 * r3=pkt(id=n,off=0,r=0)2473 * r3=pkt(id=n,off=0,r=0)
2463 *2474 *
2464 * Type 3/4:2475 * pkt_data in src register:
2465 *2476 *
2466 * r2 = r3;2477 * r2 = r3;
2467 * r2 += 8;2478 * r2 += 8;
@@ -2479,7 +2490,9 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, · 11 unmodified lines
2479 * r3=pkt(id=n,off=0,r=0)2490 * r3=pkt(id=n,off=0,r=0)
2480 *2491 *
2481 * Find register r3 and mark its range as r3=pkt(id=n,off=0,r=8)2492 * 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.
2483 */2496 */
2484 2497
2485 /* If our ids match, then we must have the same max_value. And we2498 /* 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
2490 for (i = 0; i < MAX_BPF_REG; i++)2503 for (i = 0; i < MAX_BPF_REG; i++)
2491 if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id)2504 if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id)
2492 /* keep the maximum range already checked */2505 /* 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);
2494 2507
2495 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {2508 for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) {
2496 if (state->stack_slot_type[i] != STACK_SPILL)2509 if (state->stack_slot_type[i] != STACK_SPILL)
2497 continue;2510 continue;
2498 reg = &state->spilled_regs[i / BPF_REG_SIZE];2511 reg = &state->spilled_regs[i / BPF_REG_SIZE];
2499 if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id)2512 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);
2501 }2514 }
2502}2515}
2503 2516
@@ -2861,19 +2874,43 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, · 357 unmodified lines
2861 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&2874 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGT &&
2862 dst_reg->type == PTR_TO_PACKET &&2875 dst_reg->type == PTR_TO_PACKET &&
2863 regs[insn->src_reg].type == PTR_TO_PACKET_END) {2876 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);
2865 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&2884 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLT &&
2866 dst_reg->type == PTR_TO_PACKET &&2885 dst_reg->type == PTR_TO_PACKET &&
2867 regs[insn->src_reg].type == PTR_TO_PACKET_END) {2886 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);
2869 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&2899 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JGE &&
2870 dst_reg->type == PTR_TO_PACKET_END &&2900 dst_reg->type == PTR_TO_PACKET_END &&
2871 regs[insn->src_reg].type == PTR_TO_PACKET) {2901 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);
2873 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&2909 } else if (BPF_SRC(insn->code) == BPF_X && opcode == BPF_JLE &&
2874 dst_reg->type == PTR_TO_PACKET_END &&2910 dst_reg->type == PTR_TO_PACKET_END &&
2875 regs[insn->src_reg].type == PTR_TO_PACKET) {2911 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);
2877 } else if (is_pointer_value(env, insn->dst_reg)) {2914 } else if (is_pointer_value(env, insn->dst_reg)) {
2878 verbose("R%d pointer comparison prohibited\n", insn->dst_reg);2915 verbose("R%d pointer comparison prohibited\n", insn->dst_reg);
2879 return -EACCES;2916 return -EACCES;
lib/ts_fsm.c+1−1
@@ -11,7 +11,7 @@ · 10 unmodified lines
11 * ==========================================================================11 * ==========================================================================
12 *12 *
13 * A finite state machine consists of n states (struct ts_fsm_token)13 * A finite state machine consists of n states (struct ts_fsm_token)
14 * representing the pattern as a finite automation. The data is read14 * representing the pattern as a finite automaton. The data is read
15 * sequentially on an octet basis. Every state token specifies the number15 * sequentially on an octet basis. Every state token specifies the number
16 * of recurrences and the type of value accepted which can be either a16 * of recurrences and the type of value accepted which can be either a
17 * specific character or ctype based set of characters. The available17 * specific character or ctype based set of characters. The available
lib/ts_kmp.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
27 *27 *
28 * [1] Cormen, Leiserson, Rivest, Stein28 * [1] Cormen, Leiserson, Rivest, Stein
29 * Introdcution to Algorithms, 2nd Edition, MIT Press29 * Introdcution to Algorithms, 2nd Edition, MIT Press
30 * [2] See finite automation theory30 * [2] See finite automaton theory
31 */31 */
32 32
33#include <linux/module.h>33#include <linux/module.h>
mm/memcontrol.c+0−15
@@ -5828,21 +5828,6 @@ void mem_cgroup_sk_alloc(struct sock *sk) · 5827 unmodified lines
5828 if (!mem_cgroup_sockets_enabled)5828 if (!mem_cgroup_sockets_enabled)
5829 return;5829 return;
5830 5830
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
5846 rcu_read_lock();5831 rcu_read_lock();
5847 memcg = mem_cgroup_from_task(current);5832 memcg = mem_cgroup_from_task(current);
5848 if (memcg == root_mem_cgroup)5833 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
1329 * @gfp: allocation flags1329 * @gfp: allocation flags
1330 *1330 *
1331 * Allocate percpu area of @size bytes aligned at @align. If @gfp doesn't1331 * 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.
1333 *1335 *
1334 * RETURNS:1336 * RETURNS:
1335 * Percpu pointer to the allocated area on success, NULL on failure.1337 * 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
1337static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,1339static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
1338 gfp_t gfp)1340 gfp_t gfp)
1339{1341{
1342 bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
1343 bool do_warn = !(gfp & __GFP_NOWARN);
1340 static int warn_limit = 10;1344 static int warn_limit = 10;
1341 struct pcpu_chunk *chunk;1345 struct pcpu_chunk *chunk;
1342 const char *err;1346 const char *err;
1343 bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL;
1344 int slot, off, cpu, ret;1347 int slot, off, cpu, ret;
1345 unsigned long flags;1348 unsigned long flags;
1346 void __percpu *ptr;1349 void __percpu *ptr;
@@ -1361,7 +1364,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, · 14 unmodified lines
1361 1364
1362 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||1365 if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE ||
1363 !is_power_of_2(align))) {1366 !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",
1365 size, align);1368 size, align);
1366 return NULL;1369 return NULL;
1367 }1370 }
@@ -1482,7 +1485,7 @@ fail_unlock: · 114 unmodified lines
1482fail:1485fail:
1483 trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);1486 trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
1484 1487
1485 if (!is_atomic && warn_limit) {1488 if (!is_atomic && do_warn && warn_limit) {
1486 pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",1489 pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
1487 size, align, is_atomic, err);1490 size, align, is_atomic, err);
1488 dump_stack();1491 dump_stack();
@@ -1507,7 +1510,9 @@ fail: · 18 unmodified lines
1507 *1510 *
1508 * Allocate zero-filled percpu area of @size bytes aligned at @align. If1511 * Allocate zero-filled percpu area of @size bytes aligned at @align. If
1509 * @gfp doesn't contain %GFP_KERNEL, the allocation doesn't block and can1512 * @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.
1511 *1516 *
1512 * RETURNS:1517 * RETURNS:
1513 * Percpu pointer to the allocated area on success, NULL on failure.1518 * 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
573 }573 }
574 *vinfo_last = NULL;574 *vinfo_last = NULL;
575 575
576 return 0;576 return err;
577 }577 }
578 578
579 return br_vlan_info(br, p, cmd, vinfo_curr);579 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
78static struct kmem_cache *rcv_cache __read_mostly;78static struct kmem_cache *rcv_cache __read_mostly;
79 79
80/* table of registered CAN protocols */80/* table of registered CAN protocols */
81static const struct can_proto *proto_tab[CAN_NPROTO] __read_mostly;81static const struct can_proto __rcu *proto_tab[CAN_NPROTO] __read_mostly;
82static DEFINE_MUTEX(proto_tab_lock);82static DEFINE_MUTEX(proto_tab_lock);
83 83
84static atomic_t skbcounter = ATOMIC_INIT(0);84static atomic_t skbcounter = ATOMIC_INIT(0);
@@ -788,7 +788,7 @@ int can_proto_register(const struct can_proto *cp) · 703 unmodified lines
788 788
789 mutex_lock(&proto_tab_lock);789 mutex_lock(&proto_tab_lock);
790 790
791 if (proto_tab[proto]) {791 if (rcu_access_pointer(proto_tab[proto])) {
792 pr_err("can: protocol %d already registered\n", proto);792 pr_err("can: protocol %d already registered\n", proto);
793 err = -EBUSY;793 err = -EBUSY;
794 } else794 } else
@@ -812,7 +812,7 @@ void can_proto_unregister(const struct can_proto *cp) · 17 unmodified lines
812 int proto = cp->protocol;812 int proto = cp->protocol;
813 813
814 mutex_lock(&proto_tab_lock);814 mutex_lock(&proto_tab_lock);
815 BUG_ON(proto_tab[proto] != cp);815 BUG_ON(rcu_access_pointer(proto_tab[proto]) != cp);
816 RCU_INIT_POINTER(proto_tab[proto], NULL);816 RCU_INIT_POINTER(proto_tab[proto], NULL);
817 mutex_unlock(&proto_tab_lock);817 mutex_unlock(&proto_tab_lock);
818 818
@@ -875,9 +875,14 @@ static int can_pernet_init(struct net *net) · 56 unmodified lines
875 spin_lock_init(&net->can.can_rcvlists_lock);875 spin_lock_init(&net->can.can_rcvlists_lock);
876 net->can.can_rx_alldev_list =876 net->can.can_rx_alldev_list =
877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);877 kzalloc(sizeof(struct dev_rcv_lists), GFP_KERNEL);
878 878 if (!net->can.can_rx_alldev_list)
879 goto out;
879 net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL);880 net->can.can_stats = kzalloc(sizeof(struct s_stats), GFP_KERNEL);
881 if (!net->can.can_stats)
882 goto out_free_alldev_list;
880 net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL);883 net->can.can_pstats = kzalloc(sizeof(struct s_pstats), GFP_KERNEL);
884 if (!net->can.can_pstats)
885 goto out_free_can_stats;
881 886
882 if (IS_ENABLED(CONFIG_PROC_FS)) {887 if (IS_ENABLED(CONFIG_PROC_FS)) {
883 /* the statistics are updated every second (timer triggered) */888 /* the statistics are updated every second (timer triggered) */
@@ -892,6 +897,13 @@ static int can_pernet_init(struct net *net) · 8 unmodified lines
892 }897 }
893 898
894 return 0;899 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;
895}907}
896 908
897static void can_pernet_exit(struct net *net)909static 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
1493static int bcm_release(struct socket *sock)1493static int bcm_release(struct socket *sock)
1494{1494{
1495 struct sock *sk = sock->sk;1495 struct sock *sk = sock->sk;
1496 struct net *net = sock_net(sk);1496 struct net *net;
1497 struct bcm_sock *bo;1497 struct bcm_sock *bo;
1498 struct bcm_op *op, *next;1498 struct bcm_op *op, *next;
1499 1499
1500 if (sk == NULL)1500 if (!sk)
1501 return 0;1501 return 0;
1502 1502
1503 net = sock_net(sk);
1503 bo = bcm_sk(sk);1504 bo = bcm_sk(sk);
1504 1505
1505 /* remove bcm_ops, timer, rx_unregister(), etc. */1506 /* 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
1147 return ret;1147 return ret;
1148}1148}
1149 1149
1150static int dev_get_valid_name(struct net *net,1150int dev_get_valid_name(struct net *net, struct net_device *dev,
1151 struct net_device *dev,1151 const char *name)
1152 const char *name)
1153{1152{
1154 BUG_ON(!net);1153 BUG_ON(!net);
1155 1154
@@ -1165,6 +1164,7 @@ static int dev_get_valid_name(struct net *net, · 9 unmodified lines
1165 1164
1166 return 0;1165 return 0;
1167}1166}
1167EXPORT_SYMBOL(dev_get_valid_name);
1168 1168
1169/**1169/**
1170 * dev_change_name - change name of a device1170 * 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
303 case SIOCSIFTXQLEN:303 case SIOCSIFTXQLEN:
304 if (ifr->ifr_qlen < 0)304 if (ifr->ifr_qlen < 0)
305 return -EINVAL;305 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 }
307 return 0;318 return 0;
308 319
309 case SIOCSIFNAME:320 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
436EXPORT_SYMBOL(ethtool_convert_link_mode_to_legacy_u32);436EXPORT_SYMBOL(ethtool_convert_link_mode_to_legacy_u32);
437 437
438/* return false if legacy contained non-0 deprecated fields438/* return false if legacy contained non-0 deprecated fields
439 * transceiver/maxtxpkt/maxrxpkt. rest of ksettings always updated439 * maxtxpkt/maxrxpkt. rest of ksettings always updated
440 */440 */
441static bool441static bool
442convert_legacy_settings_to_link_ksettings(442convert_legacy_settings_to_link_ksettings(
@@ -451,8 +451,7 @@ convert_legacy_settings_to_link_ksettings( · 8 unmodified lines
451 * deprecated legacy fields, and they should not use451 * deprecated legacy fields, and they should not use
452 * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS452 * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS
453 */453 */
454 if (legacy_settings->transceiver ||454 if (legacy_settings->maxtxpkt ||
455 legacy_settings->maxtxpkt ||
456 legacy_settings->maxrxpkt)455 legacy_settings->maxrxpkt)
457 retval = false;456 retval = false;
458 457
net/core/filter.c+16−15
@@ -1839,31 +1839,31 @@ static const struct bpf_func_proto bpf_redirect_proto = { · 1838 unmodified lines
1839 .arg2_type = ARG_ANYTHING,1839 .arg2_type = ARG_ANYTHING,
1840};1840};
1841 1841
1842BPF_CALL_3(bpf_sk_redirect_map, struct bpf_map *, map, u32, key, u64, flags)1842BPF_CALL_4(bpf_sk_redirect_map, struct sk_buff *, skb,
1843 struct bpf_map *, map, u32, key, u64, flags)
1843{1844{
1844 struct redirect_info *ri = this_cpu_ptr(&redirect_info);1845 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
1845 1846
1846 if (unlikely(flags))1847 if (unlikely(flags))
1847 return SK_ABORTED;1848 return SK_ABORTED;
1848 1849
1849 ri->ifindex = key;1850 tcb->bpf.key = key;
1850 ri->flags = flags;1851 tcb->bpf.flags = flags;
1851 ri->map = map;1852 tcb->bpf.map = map;
1852 1853
1853 return SK_REDIRECT;1854 return SK_REDIRECT;
1854}1855}
1855 1856
1856struct sock *do_sk_redirect_map(void)1857struct sock *do_sk_redirect_map(struct sk_buff *skb)
1857{1858{
1858 struct redirect_info *ri = this_cpu_ptr(&redirect_info);1859 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
1859 struct sock *sk = NULL;1860 struct sock *sk = NULL;
1860 1861
1861 if (ri->map) {1862 if (tcb->bpf.map) {
1862 sk = __sock_map_lookup_elem(ri->map, ri->ifindex);1863 sk = __sock_map_lookup_elem(tcb->bpf.map, tcb->bpf.key);
1863 1864
1864 ri->ifindex = 0;1865 tcb->bpf.key = 0;
1865 ri->map = NULL;1866 tcb->bpf.map = NULL;
1866 /* we do not clear flags for future lookup */
1867 }1867 }
1868 1868
1869 return sk;1869 return sk;
@@ -1873,9 +1873,10 @@ static const struct bpf_func_proto bpf_sk_redirect_map_proto = { · 3 unmodified lines
1873 .func = bpf_sk_redirect_map,1873 .func = bpf_sk_redirect_map,
1874 .gpl_only = false,1874 .gpl_only = false,
1875 .ret_type = RET_INTEGER,1875 .ret_type = RET_INTEGER,
1876 .arg1_type = ARG_CONST_MAP_PTR,1876 .arg1_type = ARG_PTR_TO_CTX,
1877 .arg2_type = ARG_ANYTHING,1877 .arg2_type = ARG_CONST_MAP_PTR,
1878 .arg3_type = ARG_ANYTHING,1878 .arg3_type = ARG_ANYTHING,
1879 .arg4_type = ARG_ANYTHING,
1879};1880};
1880 1881
1881BPF_CALL_1(bpf_get_cgroup_classid, const struct sk_buff *, skb)1882BPF_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
3683{3684{
3684 if (type == BPF_WRITE) {3685 if (type == BPF_WRITE) {
3685 switch (off) {3686 switch (off) {
3686 case bpf_ctx_range(struct __sk_buff, mark):
3687 case bpf_ctx_range(struct __sk_buff, tc_index):3687 case bpf_ctx_range(struct __sk_buff, tc_index):
3688 case bpf_ctx_range(struct __sk_buff, priority):3688 case bpf_ctx_range(struct __sk_buff, priority):
3689 break;3689 break;
@@ -3693,6 +3693,7 @@ static bool sk_skb_is_valid_access(int off, int size, · 3 unmodified lines
3693 }3693 }
3694 3694
3695 switch (off) {3695 switch (off) {
3696 case bpf_ctx_range(struct __sk_buff, mark):
3696 case bpf_ctx_range(struct __sk_buff, tc_classid):3697 case bpf_ctx_range(struct __sk_buff, tc_classid):
3697 return false;3698 return false;
3698 case bpf_ctx_range(struct __sk_buff, data):3699 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
1483 [IFLA_LINKINFO] = { .type = NLA_NESTED },1483 [IFLA_LINKINFO] = { .type = NLA_NESTED },
1484 [IFLA_NET_NS_PID] = { .type = NLA_U32 },1484 [IFLA_NET_NS_PID] = { .type = NLA_U32 },
1485 [IFLA_NET_NS_FD] = { .type = NLA_U32 },1485 [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 },
1487 [IFLA_VFINFO_LIST] = {. type = NLA_NESTED },1490 [IFLA_VFINFO_LIST] = {. type = NLA_NESTED },
1488 [IFLA_VF_PORTS] = { .type = NLA_NESTED },1491 [IFLA_VF_PORTS] = { .type = NLA_NESTED },
1489 [IFLA_PORT_SELF] = { .type = NLA_NESTED },1492 [IFLA_PORT_SELF] = { .type = NLA_NESTED },
@@ -2093,7 +2096,7 @@ static int do_setlink(const struct sk_buff *skb, · 603 unmodified lines
2093 dev->tx_queue_len = orig_len;2096 dev->tx_queue_len = orig_len;
2094 goto errout;2097 goto errout;
2095 }2098 }
2096 status |= DO_SETLINK_NOTIFY;2099 status |= DO_SETLINK_MODIFIED;
2097 }2100 }
2098 }2101 }
2099 2102
@@ -2248,7 +2251,7 @@ static int do_setlink(const struct sk_buff *skb, · 148 unmodified lines
2248 2251
2249errout:2252errout:
2250 if (status & DO_SETLINK_MODIFIED) {2253 if (status & DO_SETLINK_MODIFIED) {
2251 if (status & DO_SETLINK_NOTIFY)2254 if ((status & DO_SETLINK_NOTIFY) == DO_SETLINK_NOTIFY)
2252 netdev_state_change(dev);2255 netdev_state_change(dev);
2253 2256
2254 if (err < 0)2257 if (err < 0)
@@ -4279,13 +4282,17 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi · 2024 unmodified lines
4279 4282
4280 switch (event) {4283 switch (event) {
4281 case NETDEV_REBOOT:4284 case NETDEV_REBOOT:
4285 case NETDEV_CHANGEMTU:
4282 case NETDEV_CHANGEADDR:4286 case NETDEV_CHANGEADDR:
4283 case NETDEV_CHANGENAME:4287 case NETDEV_CHANGENAME:
4284 case NETDEV_FEAT_CHANGE:4288 case NETDEV_FEAT_CHANGE:
4285 case NETDEV_BONDING_FAILOVER:4289 case NETDEV_BONDING_FAILOVER:
4290 case NETDEV_POST_TYPE_CHANGE:
4286 case NETDEV_NOTIFY_PEERS:4291 case NETDEV_NOTIFY_PEERS:
4292 case NETDEV_CHANGEUPPER:
4287 case NETDEV_RESEND_IGMP:4293 case NETDEV_RESEND_IGMP:
4288 case NETDEV_CHANGEINFODATA:4294 case NETDEV_CHANGEINFODATA:
4295 case NETDEV_CHANGE_TX_QUEUE_LEN:
4289 rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event),4296 rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event),
4290 GFP_KERNEL);4297 GFP_KERNEL);
4291 break;4298 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
1124 1124
1125 err = __zerocopy_sg_from_iter(sk, skb, &msg->msg_iter, len);1125 err = __zerocopy_sg_from_iter(sk, skb, &msg->msg_iter, len);
1126 if (err == -EFAULT || (err == -EMSGSIZE && skb->len == orig_len)) {1126 if (err == -EFAULT || (err == -EMSGSIZE && skb->len == orig_len)) {
1127 struct sock *save_sk = skb->sk;
1128
1127 /* Streams do not free skb on error. Reset to prev state. */1129 /* Streams do not free skb on error. Reset to prev state. */
1128 msg->msg_iter = orig_iter;1130 msg->msg_iter = orig_iter;
1131 skb->sk = sk;
1129 ___pskb_trim(skb, orig_len);1132 ___pskb_trim(skb, orig_len);
1133 skb->sk = save_sk;
1130 return err;1134 return err;
1131 }1135 }
1132 1136
@@ -1896,7 +1900,7 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta) · 763 unmodified lines
1896 }1900 }
1897 1901
1898 /* If we need update frag list, we are in troubles.1902 /* 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,
1900 * but taking into account that pulling is expected to1904 * but taking into account that pulling is expected to
1901 * be very rare operation, it is worth to fight against1905 * be very rare operation, it is worth to fight against
1902 * further bloating skb head and crucify ourselves here instead.1906 * 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
1677 newsk->sk_dst_pending_confirm = 0;1677 newsk->sk_dst_pending_confirm = 0;
1678 newsk->sk_wmem_queued = 0;1678 newsk->sk_wmem_queued = 0;
1679 newsk->sk_forward_alloc = 0;1679 newsk->sk_forward_alloc = 0;
1680
1681 /* sk->sk_memcg will be populated at accept() time */
1682 newsk->sk_memcg = NULL;
1683
1680 atomic_set(&newsk->sk_drops, 0);1684 atomic_set(&newsk->sk_drops, 0);
1681 newsk->sk_send_head = NULL;1685 newsk->sk_send_head = NULL;
1682 newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;1686 newsk->sk_userlocks = sk->sk_userlocks & ~SOCK_BINDPORT_LOCK;
1683 atomic_set(&newsk->sk_zckey, 0);1687 atomic_set(&newsk->sk_zckey, 0);
1684 1688
1685 sock_reset_flag(newsk, SOCK_DONE);1689 sock_reset_flag(newsk, SOCK_DONE);
1690 cgroup_sk_alloc(&newsk->sk_cgrp_data);
1686 1691
1687 rcu_read_lock();1692 rcu_read_lock();
1688 filter = rcu_dereference(sk->sk_filter);1693 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
1714 newsk->sk_incoming_cpu = raw_smp_processor_id();1719 newsk->sk_incoming_cpu = raw_smp_processor_id();
1715 atomic64_set(&newsk->sk_cookie, 0);1720 atomic64_set(&newsk->sk_cookie, 0);
1716 1721
1717 mem_cgroup_sk_alloc(newsk);
1718 cgroup_sk_alloc(&newsk->sk_cgrp_data);
1719
1720 /*1722 /*
1721 * Before updating sk_refcnt, we must commit prior changes to memory1723 * Before updating sk_refcnt, we must commit prior changes to memory
1722 * (Documentation/RCU/rculist_nulls.txt for details)1724 * (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
36 * soft irq of receive path or setsockopt from process context36 * soft irq of receive path or setsockopt from process context
37 */37 */
38 spin_lock_bh(&reuseport_lock);38 spin_lock_bh(&reuseport_lock);
39 WARN_ONCE(rcu_dereference_protected(sk->sk_reuseport_cb,39
40 lockdep_is_held(&reuseport_lock)),40 /* Allocation attempts can occur concurrently via the setsockopt path
41 "multiple allocations for the same socket");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
42 reuse = __reuseport_alloc(INIT_SOCKS);47 reuse = __reuseport_alloc(INIT_SOCKS);
43 if (!reuse) {48 if (!reuse) {
44 spin_unlock_bh(&reuseport_lock);49 spin_unlock_bh(&reuseport_lock);
@@ -49,6 +54,7 @@ int reuseport_alloc(struct sock *sk) · 4 unmodified lines
49 reuse->num_socks = 1;54 reuse->num_socks = 1;
50 rcu_assign_pointer(sk->sk_reuseport_cb, reuse);55 rcu_assign_pointer(sk->sk_reuseport_cb, reuse);
51 56
57out:
52 spin_unlock_bh(&reuseport_lock);58 spin_unlock_bh(&reuseport_lock);
53 59
54 return 0;60 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
414 sk_daddr_set(newsk, ireq->ir_rmt_addr);414 sk_daddr_set(newsk, ireq->ir_rmt_addr);
415 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);415 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
416 newinet->inet_saddr = ireq->ir_loc_addr;416 newinet->inet_saddr = ireq->ir_loc_addr;
417 newinet->inet_opt = ireq->opt;417 RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt));
418 ireq->opt = NULL;
419 newinet->mc_index = inet_iif(skb);418 newinet->mc_index = inet_iif(skb);
420 newinet->mc_ttl = ip_hdr(skb)->ttl;419 newinet->mc_ttl = ip_hdr(skb)->ttl;
421 newinet->inet_id = jiffies;420 newinet->inet_id = jiffies;
@@ -430,7 +429,10 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk, · 8 unmodified lines
430 if (__inet_inherit_port(sk, newsk) < 0)429 if (__inet_inherit_port(sk, newsk) < 0)
431 goto put_and_exit;430 goto put_and_exit;
432 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));431 *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;
434 return newsk;436 return newsk;
435 437
436exit_overflow:438exit_overflow:
@@ -441,6 +443,7 @@ exit: · 4 unmodified lines
441 __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);443 __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);
442 return NULL;444 return NULL;
443put_and_exit:445put_and_exit:
446 newinet->inet_opt = NULL;
444 inet_csk_prepare_forced_close(newsk);447 inet_csk_prepare_forced_close(newsk);
445 dccp_done(newsk);448 dccp_done(newsk);
446 goto exit;449 goto exit;
@@ -492,7 +495,7 @@ static int dccp_v4_send_response(const struct sock *sk, struct request_sock *req · 45 unmodified lines
492 ireq->ir_rmt_addr);495 ireq->ir_rmt_addr);
493 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,496 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
494 ireq->ir_rmt_addr,497 ireq->ir_rmt_addr,
495 ireq->opt);498 rcu_dereference(ireq->ireq_opt));
496 err = net_xmit_eval(err);499 err = net_xmit_eval(err);
497 }500 }
498 501
@@ -548,7 +551,7 @@ out: · 49 unmodified lines
548static void dccp_v4_reqsk_destructor(struct request_sock *req)551static void dccp_v4_reqsk_destructor(struct request_sock *req)
549{552{
550 dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);553 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));
552}555}
553 556
554void dccp_syn_ack_timeout(const struct request_sock *req)557void 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
70 address into account. Furthermore, the TOS (Type-Of-Service) field70 address into account. Furthermore, the TOS (Type-Of-Service) field
71 of the packet can be used for routing decisions as well.71 of the packet can be used for routing decisions as well.
72 72
73 If you are interested in this, please see the preliminary73 If you need more information, see the Linux Advanced
74 documentation at <http://www.compendium.com.ar/policy-routing.txt>74 Routing and Traffic Control documentation at
75 and <ftp://post.tepkom.ru/pub/vol2/Linux/docs/advanced-routing.tex>.75 <http://lartc.org/howto/lartc.rpdb.html>
76 You will need supporting software from
77 <ftp://ftp.tux.org/pub/net/ip-routing/>.
78 76
79 If unsure, say N.77 If unsure, say N.
80 78
net/ipv4/cipso_ipv4.c+7−17
@@ -1951,7 +1951,7 @@ int cipso_v4_req_setattr(struct request_sock *req, · 1950 unmodified lines
1951 buf = NULL;1951 buf = NULL;
1952 1952
1953 req_inet = inet_rsk(req);1953 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);
1955 if (opt)1955 if (opt)
1956 kfree_rcu(opt, rcu);1956 kfree_rcu(opt, rcu);
1957 1957
@@ -1973,11 +1973,13 @@ req_setattr_failure: · 15 unmodified lines
1973 * values on failure.1973 * values on failure.
1974 *1974 *
1975 */1975 */
1976static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr)1976static int cipso_v4_delopt(struct ip_options_rcu __rcu **opt_ptr)
1977{1977{
1978 struct ip_options_rcu *opt = rcu_dereference_protected(*opt_ptr, 1);
1978 int hdr_delta = 0;1979 int hdr_delta = 0;
1979 struct ip_options_rcu *opt = *opt_ptr;
1980 1980
1981 if (!opt || opt->opt.cipso == 0)
1982 return 0;
1981 if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) {1983 if (opt->opt.srr || opt->opt.rr || opt->opt.ts || opt->opt.router_alert) {
1982 u8 cipso_len;1984 u8 cipso_len;
1983 u8 cipso_off;1985 u8 cipso_off;
@@ -2039,14 +2041,10 @@ static int cipso_v4_delopt(struct ip_options_rcu **opt_ptr) · 55 unmodified lines
2039 */2041 */
2040void cipso_v4_sock_delattr(struct sock *sk)2042void cipso_v4_sock_delattr(struct sock *sk)
2041{2043{
2042 int hdr_delta;
2043 struct ip_options_rcu *opt;
2044 struct inet_sock *sk_inet;2044 struct inet_sock *sk_inet;
2045 int hdr_delta;
2045 2046
2046 sk_inet = inet_sk(sk);2047 sk_inet = inet_sk(sk);
2047 opt = rcu_dereference_protected(sk_inet->inet_opt, 1);
2048 if (!opt || opt->opt.cipso == 0)
2049 return;
2050 2048
2051 hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);2049 hdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);
2052 if (sk_inet->is_icsk && hdr_delta > 0) {2050 if (sk_inet->is_icsk && hdr_delta > 0) {
@@ -2066,15 +2064,7 @@ void cipso_v4_sock_delattr(struct sock *sk) · 13 unmodified lines
2066 */2064 */
2067void cipso_v4_req_delattr(struct request_sock *req)2065void cipso_v4_req_delattr(struct request_sock *req)
2068{2066{
2069 struct ip_options_rcu *opt;2067 cipso_v4_delopt(&inet_rsk(req)->ireq_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);
2078}2068}
2079 2069
2080/**2070/**
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
475 }475 }
476 spin_unlock_bh(&queue->fastopenq.lock);476 spin_unlock_bh(&queue->fastopenq.lock);
477 }477 }
478 mem_cgroup_sk_alloc(newsk);
478out:479out:
479 release_sock(sk);480 release_sock(sk);
480 if (req)481 if (req)
@@ -539,9 +540,10 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk, · 58 unmodified lines
539{540{
540 const struct inet_request_sock *ireq = inet_rsk(req);541 const struct inet_request_sock *ireq = inet_rsk(req);
541 struct net *net = read_pnet(&ireq->ireq_net);542 struct net *net = read_pnet(&ireq->ireq_net);
542 struct ip_options_rcu *opt = ireq->opt;543 struct ip_options_rcu *opt;
543 struct rtable *rt;544 struct rtable *rt;
544 545
546 opt = rcu_dereference(ireq->ireq_opt);
545 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,547 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
546 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,548 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
547 sk->sk_protocol, inet_sk_flowi_flags(sk),549 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
575 struct flowi4 *fl4;577 struct flowi4 *fl4;
576 struct rtable *rt;578 struct rtable *rt;
577 579
580 opt = rcu_dereference(ireq->ireq_opt);
578 fl4 = &newinet->cork.fl.u.ip4;581 fl4 = &newinet->cork.fl.u.ip4;
579 582
580 rcu_read_lock();
581 opt = rcu_dereference(newinet->inet_opt);
582 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,583 flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark,
583 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,584 RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
584 sk->sk_protocol, inet_sk_flowi_flags(sk),585 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
591 goto no_route;592 goto no_route;
592 if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)593 if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway)
593 goto route_err;594 goto route_err;
594 rcu_read_unlock();
595 return &rt->dst;595 return &rt->dst;
596 596
597route_err:597route_err:
598 ip_rt_put(rt);598 ip_rt_put(rt);
599no_route:599no_route:
600 rcu_read_unlock();
601 __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);600 __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
602 return NULL;601 return NULL;
603}602}
net/ipv4/inet_hashtables.c+1−4
@@ -456,10 +456,7 @@ static int inet_reuseport_add_sock(struct sock *sk, · 455 unmodified lines
456 return reuseport_add_sock(sk, sk2);456 return reuseport_add_sock(sk, sk2);
457 }457 }
458 458
459 /* Initial allocation may have already happened via setsockopt */459 return reuseport_alloc(sk);
460 if (!rcu_access_pointer(sk->sk_reuseport_cb))
461 return reuseport_alloc(sk);
462 return 0;
463}460}
464 461
465int __inet_hash(struct sock *sk, struct sock *osk)462int __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
355 /* We throwed the options of the initial SYN away, so we hope355 /* We throwed the options of the initial SYN away, so we hope
356 * the ACK carries the same options again (see RFC1122 4.2.3.8)356 * the ACK carries the same options again (see RFC1122 4.2.3.8)
357 */357 */
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));
359 359
360 if (security_inet_conn_request(sk, skb, req)) {360 if (security_inet_conn_request(sk, skb, req)) {
361 reqsk_free(req);361 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
6196 struct inet_request_sock *ireq = inet_rsk(req);6196 struct inet_request_sock *ireq = inet_rsk(req);
6197 6197
6198 kmemcheck_annotate_bitfield(ireq, flags);6198 kmemcheck_annotate_bitfield(ireq, flags);
6199 ireq->opt = NULL;6199 ireq->ireq_opt = NULL;
6200#if IS_ENABLED(CONFIG_IPV6)6200#if IS_ENABLED(CONFIG_IPV6)
6201 ireq->pktopts = NULL;6201 ireq->pktopts = NULL;
6202#endif6202#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
877 877
878 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,878 err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr,
879 ireq->ir_rmt_addr,879 ireq->ir_rmt_addr,
880 ireq->opt);880 rcu_dereference(ireq->ireq_opt));
881 err = net_xmit_eval(err);881 err = net_xmit_eval(err);
882 }882 }
883 883
@@ -889,7 +889,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, · 5 unmodified lines
889 */889 */
890static void tcp_v4_reqsk_destructor(struct request_sock *req)890static void tcp_v4_reqsk_destructor(struct request_sock *req)
891{891{
892 kfree(inet_rsk(req)->opt);892 kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
893}893}
894 894
895#ifdef CONFIG_TCP_MD5SIG895#ifdef CONFIG_TCP_MD5SIG
@@ -1265,10 +1265,11 @@ static void tcp_v4_init_req(struct request_sock *req, · 369 unmodified lines
1265 struct sk_buff *skb)1265 struct sk_buff *skb)
1266{1266{
1267 struct inet_request_sock *ireq = inet_rsk(req);1267 struct inet_request_sock *ireq = inet_rsk(req);
1268 struct net *net = sock_net(sk_listener);
1268 1269
1269 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);1270 sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
1270 sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);1271 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));
1272}1273}
1273 1274
1274static struct dst_entry *tcp_v4_route_req(const struct sock *sk,1275static 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
1355 sk_daddr_set(newsk, ireq->ir_rmt_addr);1356 sk_daddr_set(newsk, ireq->ir_rmt_addr);
1356 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);1357 sk_rcv_saddr_set(newsk, ireq->ir_loc_addr);
1357 newsk->sk_bound_dev_if = ireq->ir_iif;1358 newsk->sk_bound_dev_if = ireq->ir_iif;
1358 newinet->inet_saddr = ireq->ir_loc_addr;1359 newinet->inet_saddr = ireq->ir_loc_addr;
1359 inet_opt = ireq->opt;1360 inet_opt = rcu_dereference(ireq->ireq_opt);
1360 rcu_assign_pointer(newinet->inet_opt, inet_opt);1361 RCU_INIT_POINTER(newinet->inet_opt, inet_opt);
1361 ireq->opt = NULL;
1362 newinet->mc_index = inet_iif(skb);1362 newinet->mc_index = inet_iif(skb);
1363 newinet->mc_ttl = ip_hdr(skb)->ttl;1363 newinet->mc_ttl = ip_hdr(skb)->ttl;
1364 newinet->rcv_tos = ip_hdr(skb)->tos;1364 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
1403 if (__inet_inherit_port(sk, newsk) < 0)1403 if (__inet_inherit_port(sk, newsk) < 0)
1404 goto put_and_exit;1404 goto put_and_exit;
1405 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));1405 *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
1406 if (*own_req)1406 if (likely(*own_req)) {
1407 tcp_move_syn(newtp, req);1407 tcp_move_syn(newtp, req);
1408 1408 ireq->ireq_opt = NULL;
1409 } else {
1410 newinet->inet_opt = NULL;
1411 }
1409 return newsk;1412 return newsk;
1410 1413
1411exit_overflow:1414exit_overflow:
@@ -1416,6 +1419,7 @@ exit: · 4 unmodified lines
1416 tcp_listendrop(sk);1419 tcp_listendrop(sk);
1417 return NULL;1420 return NULL;
1418put_and_exit:1421put_and_exit:
1422 newinet->inet_opt = NULL;
1419 inet_csk_prepare_forced_close(newsk);1423 inet_csk_prepare_forced_close(newsk);
1420 tcp_done(newsk);1424 tcp_done(newsk);
1421 goto exit;1425 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
231 }231 }
232 }232 }
233 233
234 /* Initial allocation may have already happened via setsockopt */234 return reuseport_alloc(sk);
235 if (!rcu_access_pointer(sk->sk_reuseport_cb))
236 return reuseport_alloc(sk);
237 return 0;
238}235}
239 236
240/**237/**
@@ -1061,7 +1058,7 @@ back_from_confirm: · 820 unmodified lines
1061 /* ... which is an evident application bug. --ANK */1058 /* ... which is an evident application bug. --ANK */
1062 release_sock(sk);1059 release_sock(sk);
1063 1060
1064 net_dbg_ratelimited("cork app bug 2\n");1061 net_dbg_ratelimited("socket already corked\n");
1065 err = -EINVAL;1062 err = -EINVAL;
1066 goto out;1063 goto out;
1067 }1064 }
@@ -1144,7 +1141,7 @@ int udp_sendpage(struct sock *sk, struct page *page, int offset, · 76 unmodified lines
1144 if (unlikely(!up->pending)) {1141 if (unlikely(!up->pending)) {
1145 release_sock(sk);1142 release_sock(sk);
1146 1143
1147 net_dbg_ratelimited("udp cork app bug 3\n");1144 net_dbg_ratelimited("cork failed\n");
1148 return -EINVAL;1145 return -EINVAL;
1149 }1146 }
1150 1147
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
315 }315 }
316 opt_space->dst1opt = fopt->dst1opt;316 opt_space->dst1opt = fopt->dst1opt;
317 opt_space->opt_flen = fopt->opt_flen;317 opt_space->opt_flen = fopt->opt_flen;
318 opt_space->tot_len = fopt->tot_len;
318 return opt_space;319 return opt_space;
319}320}
320EXPORT_SYMBOL_GPL(fl6_merge_options);321EXPORT_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
1161 if (WARN_ON(v6_cork->opt))1161 if (WARN_ON(v6_cork->opt))
1162 return -EINVAL;1162 return -EINVAL;
1163 1163
1164 v6_cork->opt = kzalloc(opt->tot_len, sk->sk_allocation);1164 v6_cork->opt = kzalloc(sizeof(*opt), sk->sk_allocation);
1165 if (unlikely(!v6_cork->opt))1165 if (unlikely(!v6_cork->opt))
1166 return -ENOBUFS;1166 return -ENOBUFS;
1167 1167
1168 v6_cork->opt->tot_len = opt->tot_len;1168 v6_cork->opt->tot_len = sizeof(*opt);
1169 v6_cork->opt->opt_flen = opt->opt_flen;1169 v6_cork->opt->opt_flen = opt->opt_flen;
1170 v6_cork->opt->opt_nflen = opt->opt_nflen;1170 v6_cork->opt->opt_nflen = opt->opt_nflen;
1171 1171
net/l2tp/l2tp_ppp.c+3−0
@@ -988,6 +988,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session, · 987 unmodified lines
988 session->name, cmd, arg);988 session->name, cmd, arg);
989 989
990 sk = ps->sock;990 sk = ps->sock;
991 if (!sk)
992 return -EBADR;
993
991 sock_hold(sk);994 sock_hold(sk);
992 995
993 switch (cmd) {996 switch (cmd) {
net/mac80211/key.c+17−4
@@ -4,7 +4,7 @@ · 3 unmodified lines
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>5 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2013-2014 Intel Mobile Communications GmbH6 * Copyright 2013-2014 Intel Mobile Communications GmbH
7 * Copyright 2015 Intel Deutschland GmbH7 * Copyright 2015-2017 Intel Deutschland GmbH
8 *8 *
9 * This program is free software; you can redistribute it and/or modify9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as10 * 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
620 620
621 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;621 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
622 idx = key->conf.keyidx;622 idx = key->conf.keyidx;
623 key->local = sdata->local;
624 key->sdata = sdata;
625 key->sta = sta;
626 623
627 mutex_lock(&sdata->local->key_mtx);624 mutex_lock(&sdata->local->key_mtx);
628 625
@@ -633,6 +630,21 @@ int ieee80211_key_link(struct ieee80211_key *key, · 4 unmodified lines
633 else630 else
634 old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);631 old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
635 632
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
636 increment_tailroom_need_count(sdata);648 increment_tailroom_need_count(sdata);
637 649
638 ieee80211_key_replace(sdata, sta, pairwise, old_key, key);650 ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
@@ -648,6 +660,7 @@ int ieee80211_key_link(struct ieee80211_key *key, · 9 unmodified lines
648 ret = 0;660 ret = 0;
649 }661 }
650 662
663 out:
651 mutex_unlock(&sdata->local->key_mtx);664 mutex_unlock(&sdata->local->key_mtx);
652 665
653 return ret;666 return ret;
net/ncsi/internal.h+1−0
@@ -286,6 +286,7 @@ struct ncsi_dev_priv { · 285 unmodified lines
286 struct work_struct work; /* For channel management */286 struct work_struct work; /* For channel management */
287 struct packet_type ptype; /* NCSI packet Rx handler */287 struct packet_type ptype; /* NCSI packet Rx handler */
288 struct list_head node; /* Form NCSI device list */288 struct list_head node; /* Form NCSI device list */
289#define NCSI_MAX_VLAN_VIDS 15
289 struct list_head vlan_vids; /* List of active VLAN IDs */290 struct list_head vlan_vids; /* List of active VLAN IDs */
290};291};
291 292
net/ncsi/ncsi-aen.c+1−1
@@ -187,7 +187,7 @@ static struct ncsi_aen_handler { · 186 unmodified lines
187} ncsi_aen_handlers[] = {187} ncsi_aen_handlers[] = {
188 { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },188 { NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },
189 { NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr },189 { 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 }
191};191};
192 192
193int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)193int 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
189 struct ncsi_channel *nc = (struct ncsi_channel *)data;189 struct ncsi_channel *nc = (struct ncsi_channel *)data;
190 struct ncsi_package *np = nc->package;190 struct ncsi_package *np = nc->package;
191 struct ncsi_dev_priv *ndp = np->ndp;191 struct ncsi_dev_priv *ndp = np->ndp;
192 struct ncsi_channel_mode *ncm;
192 struct ncsi_cmd_arg nca;193 struct ncsi_cmd_arg nca;
193 bool enabled, chained;194 bool enabled, chained;
194 unsigned int monitor_state;195 unsigned int monitor_state;
@@ -202,11 +203,15 @@ static void ncsi_channel_monitor(unsigned long data) · 7 unmodified lines
202 monitor_state = nc->monitor.state;203 monitor_state = nc->monitor.state;
203 spin_unlock_irqrestore(&nc->lock, flags);204 spin_unlock_irqrestore(&nc->lock, flags);
204 205
205 if (!enabled || chained)206 if (!enabled || chained) {
207 ncsi_stop_channel_monitor(nc);
206 return;208 return;
209 }
207 if (state != NCSI_CHANNEL_INACTIVE &&210 if (state != NCSI_CHANNEL_INACTIVE &&
208 state != NCSI_CHANNEL_ACTIVE)211 state != NCSI_CHANNEL_ACTIVE) {
212 ncsi_stop_channel_monitor(nc);
209 return;213 return;
214 }
210 215
211 switch (monitor_state) {216 switch (monitor_state) {
212 case NCSI_CHANNEL_MONITOR_START:217 case NCSI_CHANNEL_MONITOR_START:
@@ -217,28 +222,28 @@ static void ncsi_channel_monitor(unsigned long data) · 4 unmodified lines
217 nca.type = NCSI_PKT_CMD_GLS;222 nca.type = NCSI_PKT_CMD_GLS;
218 nca.req_flags = 0;223 nca.req_flags = 0;
219 ret = ncsi_xmit_cmd(&nca);224 ret = ncsi_xmit_cmd(&nca);
220 if (ret) {225 if (ret)
221 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n",226 netdev_err(ndp->ndev.dev, "Error %d sending GLS\n",
222 ret);227 ret);
223 return;
224 }
225
226 break;228 break;
227 case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:229 case NCSI_CHANNEL_MONITOR_WAIT ... NCSI_CHANNEL_MONITOR_WAIT_MAX:
228 break;230 break;
229 default:231 default:
230 if (!(ndp->flags & NCSI_DEV_HWA) &&232 if (!(ndp->flags & NCSI_DEV_HWA)) {
231 state == NCSI_CHANNEL_ACTIVE) {
232 ncsi_report_link(ndp, true);233 ncsi_report_link(ndp, true);
233 ndp->flags |= NCSI_DEV_RESHUFFLE;234 ndp->flags |= NCSI_DEV_RESHUFFLE;
234 }235 }
235 236
237 ncsi_stop_channel_monitor(nc);
238
239 ncm = &nc->modes[NCSI_MODE_LINK];
236 spin_lock_irqsave(&nc->lock, flags);240 spin_lock_irqsave(&nc->lock, flags);
237 nc->state = NCSI_CHANNEL_INVISIBLE;241 nc->state = NCSI_CHANNEL_INVISIBLE;
242 ncm->data[2] &= ~0x1;
238 spin_unlock_irqrestore(&nc->lock, flags);243 spin_unlock_irqrestore(&nc->lock, flags);
239 244
240 spin_lock_irqsave(&ndp->lock, flags);245 spin_lock_irqsave(&ndp->lock, flags);
241 nc->state = NCSI_CHANNEL_INACTIVE;246 nc->state = NCSI_CHANNEL_ACTIVE;
242 list_add_tail_rcu(&nc->link, &ndp->channel_queue);247 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
243 spin_unlock_irqrestore(&ndp->lock, flags);248 spin_unlock_irqrestore(&ndp->lock, flags);
244 ncsi_process_next_channel(ndp);249 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
732 if (index < 0) {737 if (index < 0) {
733 netdev_err(ndp->ndev.dev,738 netdev_err(ndp->ndev.dev,
734 "Failed to add new VLAN tag, error %d\n", index);739 "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);
735 return -1;744 return -1;
736 }745 }
737 746
@@ -998,12 +1007,15 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp) · 260 unmodified lines
998 struct ncsi_package *np;1007 struct ncsi_package *np;
999 struct ncsi_channel *nc;1008 struct ncsi_channel *nc;
1000 unsigned int cap;1009 unsigned int cap;
1010 bool has_channel = false;
1001 1011
1002 /* The hardware arbitration is disabled if any one channel1012 /* The hardware arbitration is disabled if any one channel
1003 * doesn't support explicitly.1013 * doesn't support explicitly.
1004 */1014 */
1005 NCSI_FOR_EACH_PACKAGE(ndp, np) {1015 NCSI_FOR_EACH_PACKAGE(ndp, np) {
1006 NCSI_FOR_EACH_CHANNEL(np, nc) {1016 NCSI_FOR_EACH_CHANNEL(np, nc) {
1017 has_channel = true;
1018
1007 cap = nc->caps[NCSI_CAP_GENERIC].cap;1019 cap = nc->caps[NCSI_CAP_GENERIC].cap;
1008 if (!(cap & NCSI_CAP_GENERIC_HWA) ||1020 if (!(cap & NCSI_CAP_GENERIC_HWA) ||
1009 (cap & NCSI_CAP_GENERIC_HWA_MASK) !=1021 (cap & NCSI_CAP_GENERIC_HWA_MASK) !=
@@ -1014,8 +1026,13 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp) · 4 unmodified lines
1014 }1026 }
1015 }1027 }
1016 1028
1017 ndp->flags |= NCSI_DEV_HWA;1029 if (has_channel) {
1018 return true;1030 ndp->flags |= NCSI_DEV_HWA;
1031 return true;
1032 }
1033
1034 ndp->flags &= ~NCSI_DEV_HWA;
1035 return false;
1019}1036}
1020 1037
1021static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp)1038static 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
1403 1420
1404int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)1421int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1405{1422{
1406 struct ncsi_channel_filter *ncf;
1407 struct ncsi_dev_priv *ndp;1423 struct ncsi_dev_priv *ndp;
1408 unsigned int n_vids = 0;1424 unsigned int n_vids = 0;
1409 struct vlan_vid *vlan;1425 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
1420 }1436 }
1421 1437
1422 ndp = TO_NCSI_DEV_PRIV(nd);1438 ndp = TO_NCSI_DEV_PRIV(nd);
1423 ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN];
1424 1439
1425 /* Add the VLAN id to our internal list */1440 /* Add the VLAN id to our internal list */
1426 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {1441 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
1431 return 0;1446 return 0;
1432 }1447 }
1433 }1448 }
1434 1449 if (n_vids >= NCSI_MAX_VLAN_VIDS) {
1435 if (n_vids >= ncf->total) {1450 netdev_warn(dev,
1436 netdev_info(dev,1451 "tried to add vlan id %u but NCSI max already registered (%u)\n",
1437 "NCSI Channel supports up to %u VLAN tags but %u are already set\n",1452 vid, NCSI_MAX_VLAN_VIDS);
1438 ncf->total, n_vids);1453 return -ENOSPC;
1439 return -EINVAL;
1440 }1454 }
1441 1455
1442 vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);1456 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
959 { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf },959 { NCSI_PKT_RSP_EGMF, 4, ncsi_rsp_handler_egmf },
960 { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf },960 { NCSI_PKT_RSP_DGMF, 4, ncsi_rsp_handler_dgmf },
961 { NCSI_PKT_RSP_SNFC, 4, ncsi_rsp_handler_snfc },961 { 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 },
963 { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc },963 { NCSI_PKT_RSP_GC, 32, ncsi_rsp_handler_gc },
964 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp },964 { NCSI_PKT_RSP_GP, -1, ncsi_rsp_handler_gp },
965 { NCSI_PKT_RSP_GCPS, 172, ncsi_rsp_handler_gcps },965 { 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
2307 size_t tlvlen = 0;2307 size_t tlvlen = 0;
2308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);2308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
2309 unsigned int flags = 0;2309 unsigned int flags = 0;
2310 bool nlk_has_extack = nlk->flags & NETLINK_F_EXT_ACK;
2310 2311
2311 /* Error messages get the original request appened, unless the user2312 /* Error messages get the original request appened, unless the user
2312 * requests to cap the error message, and get extra error data if2313 * 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
2317 payload += nlmsg_len(nlh);2318 payload += nlmsg_len(nlh);
2318 else2319 else
2319 flags |= NLM_F_CAPPED;2320 flags |= NLM_F_CAPPED;
2320 if (nlk->flags & NETLINK_F_EXT_ACK && extack) {2321 if (nlk_has_extack && extack) {
2321 if (extack->_msg)2322 if (extack->_msg)
2322 tlvlen += nla_total_size(strlen(extack->_msg) + 1);2323 tlvlen += nla_total_size(strlen(extack->_msg) + 1);
2323 if (extack->bad_attr)2324 if (extack->bad_attr)
@@ -2326,8 +2327,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 2 unmodified lines
2326 } else {2327 } else {
2327 flags |= NLM_F_CAPPED;2328 flags |= NLM_F_CAPPED;
2328 2329
2329 if (nlk->flags & NETLINK_F_EXT_ACK &&2330 if (nlk_has_extack && extack && extack->cookie_len)
2330 extack && extack->cookie_len)
2331 tlvlen += nla_total_size(extack->cookie_len);2331 tlvlen += nla_total_size(extack->cookie_len);
2332 }2332 }
2333 2333
@@ -2355,7 +2355,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, · 21 unmodified lines
2355 errmsg->error = err;2355 errmsg->error = err;
2356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));2356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
2357 2357
2358 if (nlk->flags & NETLINK_F_EXT_ACK && extack) {2358 if (nlk_has_extack && extack) {
2359 if (err) {2359 if (err) {
2360 if (extack->_msg)2360 if (extack->_msg)
2361 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,2361 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
1769 1769
1770out:1770out:
1771 if (err && rollover) {1771 if (err && rollover) {
1772 kfree(rollover);1772 kfree_rcu(rollover, rcu);
1773 po->rollover = NULL;1773 po->rollover = NULL;
1774 }1774 }
1775 mutex_unlock(&fanout_mutex);1775 mutex_unlock(&fanout_mutex);
@@ -1796,8 +1796,10 @@ static struct packet_fanout *fanout_release(struct sock *sk) · 20 unmodified lines
1796 else1796 else
1797 f = NULL;1797 f = NULL;
1798 1798
1799 if (po->rollover)1799 if (po->rollover) {
1800 kfree_rcu(po->rollover, rcu);1800 kfree_rcu(po->rollover, rcu);
1801 po->rollover = NULL;
1802 }
1801 }1803 }
1802 mutex_unlock(&fanout_mutex);1804 mutex_unlock(&fanout_mutex);
1803 1805
@@ -3851,6 +3853,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, · 2047 unmodified lines
3851 void *data = &val;3853 void *data = &val;
3852 union tpacket_stats_u st;3854 union tpacket_stats_u st;
3853 struct tpacket_rollover_stats rstats;3855 struct tpacket_rollover_stats rstats;
3856 struct packet_rollover *rollover;
3854 3857
3855 if (level != SOL_PACKET)3858 if (level != SOL_PACKET)
3856 return -ENOPROTOOPT;3859 return -ENOPROTOOPT;
@@ -3929,13 +3932,18 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, · 72 unmodified lines
3929 0);3932 0);
3930 break;3933 break;
3931 case PACKET_ROLLOVER_STATS:3934 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)
3933 return -EINVAL;3946 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);
3939 break;3947 break;
3940 case PACKET_TX_HAS_OFF:3948 case PACKET_TX_HAS_OFF:
3941 val = po->tp_tx_has_off;3949 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
308 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len,308 call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len,
309 gfp);309 gfp);
310 /* The socket has been unlocked. */310 /* The socket has been unlocked. */
311 if (!IS_ERR(call))311 if (!IS_ERR(call)) {
312 call->notify_rx = notify_rx;312 call->notify_rx = notify_rx;
313 mutex_unlock(&call->user_mutex);
314 }
313 315
314 mutex_unlock(&call->user_mutex);
315 _leave(" = %p", call);316 _leave(" = %p", call);
316 return call;317 return call;
317}318}
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
234 tc_cls_common_offload_init(&cls_flower.common, tp);234 tc_cls_common_offload_init(&cls_flower.common, tp);
235 cls_flower.command = TC_CLSFLOWER_DESTROY;235 cls_flower.command = TC_CLSFLOWER_DESTROY;
236 cls_flower.cookie = (unsigned long) f;236 cls_flower.cookie = (unsigned long) f;
237 cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
237 238
238 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, &cls_flower);239 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER, &cls_flower);
239}240}
@@ -289,6 +290,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) · 49 unmodified lines
289 cls_flower.command = TC_CLSFLOWER_STATS;290 cls_flower.command = TC_CLSFLOWER_STATS;
290 cls_flower.cookie = (unsigned long) f;291 cls_flower.cookie = (unsigned long) f;
291 cls_flower.exts = &f->exts;292 cls_flower.exts = &f->exts;
293 cls_flower.egress_dev = f->hw_dev != tp->q->dev_queue->dev;
292 294
293 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,295 dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CLSFLOWER,
294 &cls_flower);296 &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
421{421{
422 struct dst_entry *dst;422 struct dst_entry *dst;
423 423
424 if (!t)424 if (sock_owned_by_user(sk) || !t)
425 return;425 return;
426 dst = sctp_transport_dst_check(t);426 dst = sctp_transport_dst_check(t);
427 if (dst)427 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
4906 struct socket *sock;4906 struct socket *sock;
4907 int err = 0;4907 int err = 0;
4908 4908
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
4909 if (!asoc)4913 if (!asoc)
4910 return -EINVAL;4914 return -EINVAL;
4911 4915
net/vmw_vsock/hyperv_transport.c+18−4
@@ -310,11 +310,15 @@ static void hvs_close_connection(struct vmbus_channel *chan) · 309 unmodified lines
310 struct sock *sk = get_per_channel_state(chan);310 struct sock *sk = get_per_channel_state(chan);
311 struct vsock_sock *vsk = vsock_sk(sk);311 struct vsock_sock *vsk = vsock_sk(sk);
312 312
313 lock_sock(sk);
314
313 sk->sk_state = SS_UNCONNECTED;315 sk->sk_state = SS_UNCONNECTED;
314 sock_set_flag(sk, SOCK_DONE);316 sock_set_flag(sk, SOCK_DONE);
315 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN;317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN;
316 318
317 sk->sk_state_change(sk);319 sk->sk_state_change(sk);
320
321 release_sock(sk);
318}322}
319 323
320static void hvs_open_connection(struct vmbus_channel *chan)324static void hvs_open_connection(struct vmbus_channel *chan)
@@ -344,6 +348,8 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 23 unmodified lines
344 if (!sk)348 if (!sk)
345 return;349 return;
346 350
351 lock_sock(sk);
352
347 if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) ||353 if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) ||
348 (!conn_from_host && sk->sk_state != SS_CONNECTING))354 (!conn_from_host && sk->sk_state != SS_CONNECTING))
349 goto out;355 goto out;
@@ -395,9 +401,7 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 45 unmodified lines
395 401
396 vsock_insert_connected(vnew);402 vsock_insert_connected(vnew);
397 403
398 lock_sock(sk);
399 vsock_enqueue_accept(sk, new);404 vsock_enqueue_accept(sk, new);
400 release_sock(sk);
401 } else {405 } else {
402 sk->sk_state = SS_CONNECTED;406 sk->sk_state = SS_CONNECTED;
403 sk->sk_socket->state = SS_CONNECTED;407 sk->sk_socket->state = SS_CONNECTED;
@@ -410,6 +414,8 @@ static void hvs_open_connection(struct vmbus_channel *chan) · 6 unmodified lines
410out:414out:
411 /* Release refcnt obtained when we called vsock_find_bound_socket() */415 /* Release refcnt obtained when we called vsock_find_bound_socket() */
412 sock_put(sk);416 sock_put(sk);
417
418 release_sock(sk);
413}419}
414 420
415static u32 hvs_get_local_cid(void)421static u32 hvs_get_local_cid(void)
@@ -476,13 +482,21 @@ out: · 60 unmodified lines
476 482
477static void hvs_release(struct vsock_sock *vsk)483static void hvs_release(struct vsock_sock *vsk)
478{484{
485 struct sock *sk = sk_vsock(vsk);
479 struct hvsock *hvs = vsk->trans;486 struct hvsock *hvs = vsk->trans;
480 struct vmbus_channel *chan = hvs->chan;487 struct vmbus_channel *chan;
481 488
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;
482 if (chan)497 if (chan)
483 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN);498 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN);
484 499
485 vsock_remove_sock(vsk);
486}500}
487 501
488static void hvs_destruct(struct vsock_sock *vsk)502static 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
62 ret = 1;62 ret = 1;
63 63
64 bpf_printk("sockmap: %d -> %d @ %d\n", lport, bpf_ntohl(rport), ret);64 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);
66}66}
67 67
68SEC("sockops")68SEC("sockops")
tools/include/uapi/linux/bpf.h+2−1
@@ -569,9 +569,10 @@ union bpf_attr { · 568 unmodified lines
569 * @flags: reserved for future use569 * @flags: reserved for future use
570 * Return: 0 on success or negative error code570 * Return: 0 on success or negative error code
571 *571 *
572 * int bpf_sk_redirect_map(map, key, flags)572 * int bpf_sk_redirect_map(skb, map, key, flags)
573 * Redirect skb to a sock in map using key as a lookup key for the573 * Redirect skb to a sock in map using key as a lookup key for the
574 * sock in map.574 * sock in map.
575 * @skb: pointer to skb
575 * @map: pointer to sockmap576 * @map: pointer to sockmap
576 * @key: key to lookup sock in map577 * @key: key to lookup sock in map
577 * @flags: reserved for future use578 * @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
65static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval,65static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval,
66 int optlen) =66 int optlen) =
67 (void *) BPF_FUNC_setsockopt;67 (void *) BPF_FUNC_setsockopt;
68static int (*bpf_sk_redirect_map)(void *map, int key, int flags) =68static int (*bpf_sk_redirect_map)(void *ctx, void *map, int key, int flags) =
69 (void *) BPF_FUNC_sk_redirect_map;69 (void *) BPF_FUNC_sk_redirect_map;
70static int (*bpf_sock_map_update)(void *map, void *key, void *value,70static int (*bpf_sock_map_update)(void *map, void *key, void *value,
71 unsigned long long flags) =71 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
61 bpf_printk("verdict: data[0] = redir(%u:%u)\n", map, sk);61 bpf_printk("verdict: data[0] = redir(%u:%u)\n", map, sk);
62 62
63 if (!map)63 if (!map)
64 return bpf_sk_redirect_map(&sock_map_rx, sk, 0);64 return bpf_sk_redirect_map(skb, &sock_map_rx, sk, 0);
65 return bpf_sk_redirect_map(&sock_map_tx, sk, 0);65 return bpf_sk_redirect_map(skb, &sock_map_tx, sk, 0);
66}66}
67 67
68char _license[] SEC("license") = "GPL";68char _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
466 int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc;466 int one = 1, map_fd_rx, map_fd_tx, map_fd_break, s, sc, rc;
467 struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break;467 struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_break;
468 int ports[] = {50200, 50201, 50202, 50204};468 int ports[] = {50200, 50201, 50202, 50204};
469 int err, i, fd, sfd[6] = {0xdeadbeef};469 int err, i, fd, udp, sfd[6] = {0xdeadbeef};
470 u8 buf[20] = {0x0, 0x5, 0x3, 0x2, 0x1, 0x0};470 u8 buf[20] = {0x0, 0x5, 0x3, 0x2, 0x1, 0x0};
471 int parse_prog, verdict_prog;471 int parse_prog, verdict_prog;
472 struct sockaddr_in addr;472 struct sockaddr_in addr;
@@ -548,6 +548,16 @@ static void test_sockmap(int tasks, void *data) · 75 unmodified lines
548 goto out_sockmap;548 goto out_sockmap;
549 }549 }
550 550
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
551 /* Test update without programs */561 /* Test update without programs */
552 for (i = 0; i < 6; i++) {562 for (i = 0; i < 6; i++) {
553 err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY);563 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
1130 .errstr = "invalid bpf_context access",1130 .errstr = "invalid bpf_context access",
1131 },1131 },
1132 {1132 {
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",
1134 .insns = {1145 .insns = {
1135 BPF_MOV64_IMM(BPF_REG_0, 0),1146 BPF_MOV64_IMM(BPF_REG_0, 0),
1136 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0,1147 BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_0,
1137 offsetof(struct __sk_buff, mark)),1148 offsetof(struct __sk_buff, mark)),
1138 BPF_EXIT_INSN(),1149 BPF_EXIT_INSN(),
1139 },1150 },
1140 .result = ACCEPT,1151 .result = REJECT,
1141 .prog_type = BPF_PROG_TYPE_SK_SKB,1152 .prog_type = BPF_PROG_TYPE_SK_SKB,
1153 .errstr = "invalid bpf_context access",
1142 },1154 },
1143 {1155 {
1144 "check skb->tc_index is writeable by SK_SKB",1156 "check skb->tc_index is writeable by SK_SKB",
@@ -6645,6 +6657,500 @@ static struct bpf_test tests[] = { · 5500 unmodified lines
6645 .errstr = "BPF_END uses reserved fields",6657 .errstr = "BPF_END uses reserved fields",
6646 .result = REJECT,6658 .result = REJECT,
6647 },6659 },
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 },
6648};7154};
6649 7155
6650static int probe_filter_length(const struct bpf_insn *fp)7156static 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