1. 14 10月, 2022 1 次提交
    • J
      i40e: Fix DMA mappings leak · aae425ef
      Jan Sokolowski 提交于
      During reallocation of RX buffers, new DMA mappings are created for
      those buffers.
      
      steps for reproduction:
      while :
      do
      for ((i=0; i<=8160; i=i+32))
      do
      ethtool -G enp130s0f0 rx $i tx $i
      sleep 0.5
      ethtool -g enp130s0f0
      done
      done
      
      This resulted in crash:
      i40e 0000:01:00.1: Unable to allocate memory for the Rx descriptor ring, size=65536
      Driver BUG
      WARNING: CPU: 0 PID: 4300 at net/core/xdp.c:141 xdp_rxq_info_unreg+0x43/0x50
      Call Trace:
      i40e_free_rx_resources+0x70/0x80 [i40e]
      i40e_set_ringparam+0x27c/0x800 [i40e]
      ethnl_set_rings+0x1b2/0x290
      genl_family_rcv_msg_doit.isra.15+0x10f/0x150
      genl_family_rcv_msg+0xb3/0x160
      ? rings_fill_reply+0x1a0/0x1a0
      genl_rcv_msg+0x47/0x90
      ? genl_family_rcv_msg+0x160/0x160
      netlink_rcv_skb+0x4c/0x120
      genl_rcv+0x24/0x40
      netlink_unicast+0x196/0x230
      netlink_sendmsg+0x204/0x3d0
      sock_sendmsg+0x4c/0x50
      __sys_sendto+0xee/0x160
      ? handle_mm_fault+0xbe/0x1e0
      ? syscall_trace_enter+0x1d3/0x2c0
      __x64_sys_sendto+0x24/0x30
      do_syscall_64+0x5b/0x1a0
      entry_SYSCALL_64_after_hwframe+0x65/0xca
      RIP: 0033:0x7f5eac8b035b
      Missing register, driver bug
      WARNING: CPU: 0 PID: 4300 at net/core/xdp.c:119 xdp_rxq_info_unreg_mem_model+0x69/0x140
      Call Trace:
      xdp_rxq_info_unreg+0x1e/0x50
      i40e_free_rx_resources+0x70/0x80 [i40e]
      i40e_set_ringparam+0x27c/0x800 [i40e]
      ethnl_set_rings+0x1b2/0x290
      genl_family_rcv_msg_doit.isra.15+0x10f/0x150
      genl_family_rcv_msg+0xb3/0x160
      ? rings_fill_reply+0x1a0/0x1a0
      genl_rcv_msg+0x47/0x90
      ? genl_family_rcv_msg+0x160/0x160
      netlink_rcv_skb+0x4c/0x120
      genl_rcv+0x24/0x40
      netlink_unicast+0x196/0x230
      netlink_sendmsg+0x204/0x3d0
      sock_sendmsg+0x4c/0x50
      __sys_sendto+0xee/0x160
      ? handle_mm_fault+0xbe/0x1e0
      ? syscall_trace_enter+0x1d3/0x2c0
      __x64_sys_sendto+0x24/0x30
      do_syscall_64+0x5b/0x1a0
      entry_SYSCALL_64_after_hwframe+0x65/0xca
      RIP: 0033:0x7f5eac8b035b
      
      This was caused because of new buffers with different RX ring count should
      substitute older ones, but those buffers were freed in
      i40e_configure_rx_ring and reallocated again with i40e_alloc_rx_bi,
      thus kfree on rx_bi caused leak of already mapped DMA.
      
      Fix this by reallocating ZC with rx_bi_zc struct when BPF program loads. Additionally
      reallocate back to rx_bi when BPF program unloads.
      
      If BPF program is loaded/unloaded and XSK pools are created, reallocate
      RX queues accordingly in XSP_SETUP_XSK_POOL handler.
      
      Fixes: be1222b5 ("i40e: Separate kernel allocated rx_bi rings from AF_XDP rings")
      Signed-off-by: NJan Sokolowski <jan.sokolowski@intel.com>
      Signed-off-by: NMateusz Palczewski <mateusz.palczewski@intel.com>
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Chandan <chandanx.rout@intel.com> (A Contingent Worker at Intel)
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aae425ef
  2. 03 9月, 2022 1 次提交
  3. 16 8月, 2022 1 次提交
  4. 01 7月, 2022 1 次提交
  5. 25 6月, 2022 1 次提交
  6. 22 6月, 2022 1 次提交
  7. 15 6月, 2022 1 次提交
  8. 13 4月, 2022 2 次提交
    • J
      i40e: Add tx_stopped stat · f728fa01
      Joe Damato 提交于
      Track TX queue stop events and export the new stat with ethtool.
      Signed-off-by: NJoe Damato <jdamato@fastly.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      f728fa01
    • J
      i40e: Add support for MPLS + TSO · b4fb2d33
      Joe Damato 提交于
      This change adds support for TSO of MPLS packets.
      
      In my tests with tcpdump it seems to work. Note this test setup has
      a 9000 byte MTU:
      
      MPLS (label 100, exp 0, [S], ttl 64) IP srcip.50086 > dstip.1234:
        Flags [P.], seq 593345:644401, ack 0, win 420,
        options [nop,nop,TS val 45022534 ecr 1722291395], length 51056
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 593345, win 122,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 602289, win 105,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 620177, win 71,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      MPLS (label 100, exp 0, [S], ttl 64) IP srcip.50086 > dstip.1234:
        Flags [P.], seq 644401:655953, ack 0, win 420,
        options [nop,nop,TS val 45022534 ecr 1722291395], length 11552
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 638065, win 37,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 644401, win 25,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 653345, win 8,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      
      IP dstip.1234 > srcip.50086: Flags [.], ack 655953, win 3,
        options [nop,nop,TS val 1722291395 ecr 45022534], length 0
      Signed-off-by: NJoe Damato <jdamato@fastly.com>
      Co-developed-by: NMike Gallo <mgallo@fastly.com>
      Signed-off-by: NMike Gallo <mgallo@fastly.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      b4fb2d33
  9. 09 2月, 2022 4 次提交
  10. 28 1月, 2022 1 次提交
  11. 29 12月, 2021 1 次提交
  12. 14 12月, 2021 1 次提交
  13. 20 8月, 2021 1 次提交
  14. 23 7月, 2021 1 次提交
  15. 25 6月, 2021 1 次提交
    • T
      intel: Remove rcu_read_lock() around XDP program invocation · 49589b23
      Toke Høiland-Jørgensen 提交于
      The Intel drivers all have rcu_read_lock()/rcu_read_unlock() pairs around
      XDP program invocations. However, the actual lifetime of the objects
      referred by the XDP program invocation is longer, all the way through to
      the call to xdp_do_flush(), making the scope of the rcu_read_lock() too
      small. This turns out to be harmless because it all happens in a single
      NAPI poll cycle (and thus under local_bh_disable()), but it makes the
      rcu_read_lock() misleading.
      
      Rather than extend the scope of the rcu_read_lock(), just get rid of it
      entirely. With the addition of RCU annotations to the XDP_REDIRECT map
      types that take bh execution into account, lockdep even understands this to
      be safe, so there's really no reason to keep it around.
      Signed-off-by: NToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: Jesper Dangaard Brouer <brouer@redhat.com> # i40e
      Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
      Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
      Cc: intel-wired-lan@lists.osuosl.org
      Link: https://lore.kernel.org/bpf/20210624160609.292325-12-toke@redhat.com
      49589b23
  16. 03 6月, 2021 1 次提交
  17. 08 5月, 2021 1 次提交
    • M
      i40e: fix broken XDP support · ae4393df
      Magnus Karlsson 提交于
      Commit 12738ac4 ("i40e: Fix sparse errors in i40e_txrx.c") broke
      XDP support in the i40e driver. That commit was fixing a sparse error
      in the code by introducing a new variable xdp_res instead of
      overloading this into the skb pointer. The problem is that the code
      later uses the skb pointer in if statements and these where not
      extended to also test for the new xdp_res variable. Fix this by adding
      the correct tests for xdp_res in these places.
      
      The skb pointer was used to store the result of the XDP program by
      overloading the results in the error pointer
      ERR_PTR(-result). Therefore, the allocation failure test that used to
      only test for !skb now need to be extended to also consider !xdp_res.
      
      i40e_cleanup_headers() had a check that based on the skb value being
      an error pointer, i.e. a result from the XDP program != XDP_PASS, and
      if so start to process a new packet immediately, instead of populating
      skb fields and sending the skb to the stack. This check is not needed
      anymore, since we have added an explicit test for xdp_res being set
      and if so just do continue to pick the next packet from the NIC.
      
      Fixes: 12738ac4 ("i40e: Fix sparse errors in i40e_txrx.c")
      Acked-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Tested-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Reported-by: NJesper Dangaard Brouer <brouer@redhat.com>
      Reviewed-by: NMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: NMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      ae4393df
  18. 09 4月, 2021 1 次提交
  19. 24 3月, 2021 1 次提交
  20. 18 3月, 2021 1 次提交
  21. 12 3月, 2021 1 次提交
  22. 20 2月, 2021 1 次提交
    • N
      i40e: Fix endianness conversions · b32cddd2
      Norbert Ciosek 提交于
      Fixes the following sparse warnings:
      i40e_main.c:5953:32: warning: cast from restricted __le16
      i40e_main.c:8008:29: warning: incorrect type in assignment (different base types)
      i40e_main.c:8008:29:    expected unsigned int [assigned] [usertype] ipa
      i40e_main.c:8008:29:    got restricted __le32 [usertype]
      i40e_main.c:8008:29: warning: incorrect type in assignment (different base types)
      i40e_main.c:8008:29:    expected unsigned int [assigned] [usertype] ipa
      i40e_main.c:8008:29:    got restricted __le32 [usertype]
      i40e_txrx.c:1950:59: warning: incorrect type in initializer (different base types)
      i40e_txrx.c:1950:59:    expected unsigned short [usertype] vlan_tag
      i40e_txrx.c:1950:59:    got restricted __le16 [usertype] l2tag1
      i40e_txrx.c:1953:40: warning: cast to restricted __le16
      i40e_xsk.c:448:38: warning: invalid assignment: |=
      i40e_xsk.c:448:38:    left side has type restricted __le64
      i40e_xsk.c:448:38:    right side has type int
      
      Fixes: 2f4b411a ("i40e: Enable cloud filters via tc-flower")
      Fixes: 2a508c64 ("i40e: fix VLAN.TCI == 0 RX HW offload")
      Fixes: 3106c580 ("i40e: Use batched xsk Tx interfaces to increase performance")
      Fixes: 8f88b303 ("i40e: Add infrastructure for queue channel support")
      Signed-off-by: NNorbert Ciosek <norbertx.ciosek@intel.com>
      Tested-by: NTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      b32cddd2
  23. 19 2月, 2021 1 次提交
  24. 13 2月, 2021 3 次提交
  25. 11 2月, 2021 2 次提交
    • P
      i40e: VLAN field for flow director · a9219b33
      Przemyslaw Patynowski 提交于
      Allow user to specify VLAN field and add it to flow director. Show VLAN
      field in "ethtool -n ethx" command.
      Handle VLAN type and tag field provided by ethtool command. Refactored
      filter addition, by replacing static arrays with runtime dummy packet
      creation, which allows specifying VLAN field.
      Previously, VLAN field was omitted.
      Signed-off-by: NPrzemyslaw Patynowski <przemyslawx.patynowski@intel.com>
      Tested-by: NTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      a9219b33
    • P
      i40e: Add flow director support for IPv6 · efca91e8
      Przemyslaw Patynowski 提交于
      Flow director for IPv6 is not supported.
      1) Implementation of support for IPv6 flow director.
      2) Added handlers for addition of TCP6, UDP6, SCTP6, IPv6.
      3) Refactored legacy code to make it more generic.
      4) Added packet templates for TCP6, UDP6, SCTP6, IPv6.
      5) Added handling of IPv6 source and destination address for flow director.
      6) Improved argument passing for source and destination portin TCP6, UDP6
         and SCTP6.
      7) Added handling of ethtool -n for IPv6, TCP6,UDP6, SCTP6.
      8) Used correct bit flag regarding FLEXOFF field of flow director data
         descriptor.
      
      Without this patch, there would be no support for flow director on IPv6,
      TCP6, UDP6, SCTP6.
      Tested based on x710 datasheet by using:
      ethtool -N enp133s0f0 flow-type tcp4 src-port 13 dst-port 37 user-def 0x44142 action 1
      ethtool -N enp133s0f0 flow-type tcp6 src-port 13 dst-port 40 user-def 0x44142 action 2
      ethtool -N enp133s0f0 flow-type udp4 src-port 20 dst-port 40 user-def 0x44142 action 3
      ethtool -N enp133s0f0 flow-type udp6 src-port 25 dst-port 40 user-def 0x44142 action 4
      ethtool -N enp133s0f0 flow-type sctp4 src-port 55 dst-port 65 user-def 0x44142 action 5
      ethtool -N enp133s0f0 flow-type sctp6 src-port 60 dst-port 40 user-def 0x44142 action 6
      ethtool -N enp133s0f0 flow-type ip4 src-ip 1.1.1.1 dst-ip 1.1.1.4 user-def 0x44142 action 7
      ethtool -N enp133s0f0 flow-type ip6 src-ip fe80::3efd:feff:fe6f:bbbb dst-ip fe80::3efd:feff:fe6f:aaaa user-def 0x44142 action 8
      Then send traffic from client which matches the criteria provided to ethtool.
      Observe that packets are redirected to user set queues with ethtool -S <interface>
      Signed-off-by: NPrzemyslaw Patynowski <przemyslawx.patynowski@intel.com>
      Tested-by: NTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      efca91e8
  26. 05 2月, 2021 1 次提交
  27. 09 1月, 2021 2 次提交
  28. 10 12月, 2020 1 次提交
    • B
      i40e: avoid premature Rx buffer reuse · 75aab4e1
      Björn Töpel 提交于
      The page recycle code, incorrectly, relied on that a page fragment
      could not be freed inside xdp_do_redirect(). This assumption leads to
      that page fragments that are used by the stack/XDP redirect can be
      reused and overwritten.
      
      To avoid this, store the page count prior invoking xdp_do_redirect().
      
      Longer explanation:
      
      Intel NICs have a recycle mechanism. The main idea is that a page is
      split into two parts. One part is owned by the driver, one part might
      be owned by someone else, such as the stack.
      
      t0: Page is allocated, and put on the Rx ring
                    +---------------
      used by NIC ->| upper buffer
      (rx_buffer)   +---------------
                    | lower buffer
                    +---------------
        page count  == USHRT_MAX
        rx_buffer->pagecnt_bias == USHRT_MAX
      
      t1: Buffer is received, and passed to the stack (e.g.)
                    +---------------
                    | upper buff (skb)
                    +---------------
      used by NIC ->| lower buffer
      (rx_buffer)   +---------------
        page count  == USHRT_MAX
        rx_buffer->pagecnt_bias == USHRT_MAX - 1
      
      t2: Buffer is received, and redirected
                    +---------------
                    | upper buff (skb)
                    +---------------
      used by NIC ->| lower buffer
      (rx_buffer)   +---------------
      
      Now, prior calling xdp_do_redirect():
        page count  == USHRT_MAX
        rx_buffer->pagecnt_bias == USHRT_MAX - 2
      
      This means that buffer *cannot* be flipped/reused, because the skb is
      still using it.
      
      The problem arises when xdp_do_redirect() actually frees the
      segment. Then we get:
        page count  == USHRT_MAX - 1
        rx_buffer->pagecnt_bias == USHRT_MAX - 2
      
      From a recycle perspective, the buffer can be flipped and reused,
      which means that the skb data area is passed to the Rx HW ring!
      
      To work around this, the page count is stored prior calling
      xdp_do_redirect().
      
      Note that this is not optimal, since the NIC could actually reuse the
      "lower buffer" again. However, then we need to track whether
      XDP_REDIRECT consumed the buffer or not.
      
      Fixes: d9314c47 ("i40e: add support for XDP_REDIRECT")
      Reported-and-analyzed-by: NLi RongQing <lirongqing@baidu.com>
      Signed-off-by: NBjörn Töpel <bjorn.topel@intel.com>
      Tested-by: NGeorge Kuruvinakunnel <george.kuruvinakunnel@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      75aab4e1
  29. 01 12月, 2020 1 次提交
  30. 18 11月, 2020 1 次提交
  31. 26 9月, 2020 1 次提交
    • J
      intel-ethernet: clean up W=1 warnings in kdoc · b50f7bca
      Jesse Brandeburg 提交于
      This takes care of all of the trivial W=1 fixes in the Intel
      Ethernet drivers, which allows developers and maintainers to
      build more of the networking tree with more complete warning
      checks.
      
      There are three classes of kdoc warnings fixed:
       - cannot understand function prototype: 'x'
       - Excess function parameter 'x' description in 'y'
       - Function parameter or member 'x' not described in 'y'
      
      All of the changes were trivial comment updates on
      function headers.
      
      Inspired by Lee Jones' series of wireless work to do the same.
      Compile tested only, and passes simple test of
      $ git ls-files *.[ch] | egrep drivers/net/ethernet/intel | \
        xargs scripts/kernel-doc -none
      Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
      Tested-by: NAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b50f7bca
  32. 15 9月, 2020 1 次提交