09 Nov, 2022

13 commits

  • commit a5b983c6073140b624f64e79fea6d33c3e4315a0 upstream.

    We currently pass the entire elements to the rx_bcn_presp()
    method, but only need mesh_config. Additionally, we use the
    length of the elements to calculate back the entire frame's
    length, but that's confusing - just pass the length of the
    frame instead.

    Link: https://lore.kernel.org/r/20210920154009.a18ed3d2da6c.I1824b773a0fbae4453e1433c184678ca14e8df45@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 864f2d3482f4bd0c62b355e35ee8300be8ef488e)

    Johannes Berg
     
  • commit 8e30538eca016de8e252bef174beadecd64239f0 upstream.

    The dma_map_single() doesn't permit zero length mapping. It causes a follow
    panic.

    A panic was reported on arm64:

    [ 60.137988] ------------[ cut here ]------------
    [ 60.142630] kernel BUG at kernel/dma/swiotlb.c:624!
    [ 60.147508] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
    [ 60.152992] Modules linked in: dw_hdmi_cec crct10dif_ce simple_bridge rcar_fdp1 vsp1 rcar_vin videobuf2_vmalloc rcar_csi2 v4l
    2_mem2mem videobuf2_dma_contig videobuf2_memops pci_endpoint_test videobuf2_v4l2 videobuf2_common rcar_fcp v4l2_fwnode v4l2_asyn
    c videodev mc gpio_bd9571mwv max9611 pwm_rcar ccree at24 authenc libdes phy_rcar_gen3_usb3 usb_dmac display_connector pwm_bl
    [ 60.186252] CPU: 0 PID: 508 Comm: pcitest Not tainted 6.0.0-rc1rpci-dev+ #237
    [ 60.193387] Hardware name: Renesas Salvator-X 2nd version board based on r8a77951 (DT)
    [ 60.201302] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [ 60.208263] pc : swiotlb_tbl_map_single+0x2c0/0x590
    [ 60.213149] lr : swiotlb_map+0x88/0x1f0
    [ 60.216982] sp : ffff80000a883bc0
    [ 60.220292] x29: ffff80000a883bc0 x28: 0000000000000000 x27: 0000000000000000
    [ 60.227430] x26: 0000000000000000 x25: ffff0004c0da20d0 x24: ffff80000a1f77c0
    [ 60.234567] x23: 0000000000000002 x22: 0001000040000010 x21: 000000007a000000
    [ 60.241703] x20: 0000000000200000 x19: 0000000000000000 x18: 0000000000000000
    [ 60.248840] x17: 0000000000000000 x16: 0000000000000000 x15: ffff0006ff7b9180
    [ 60.255977] x14: ffff0006ff7b9180 x13: 0000000000000000 x12: 0000000000000000
    [ 60.263113] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
    [ 60.270249] x8 : 0001000000000010 x7 : ffff0004c6754b20 x6 : 0000000000000000
    [ 60.277385] x5 : ffff0004c0da2090 x4 : 0000000000000000 x3 : 0000000000000001
    [ 60.284521] x2 : 0000000040000000 x1 : 0000000000000000 x0 : 0000000040000010
    [ 60.291658] Call trace:
    [ 60.294100] swiotlb_tbl_map_single+0x2c0/0x590
    [ 60.298629] swiotlb_map+0x88/0x1f0
    [ 60.302115] dma_map_page_attrs+0x188/0x230
    [ 60.306299] pci_endpoint_test_ioctl+0x5e4/0xd90 [pci_endpoint_test]
    [ 60.312660] __arm64_sys_ioctl+0xa8/0xf0
    [ 60.316583] invoke_syscall+0x44/0x108
    [ 60.320334] el0_svc_common.constprop.0+0xcc/0xf0
    [ 60.325038] do_el0_svc+0x2c/0xb8
    [ 60.328351] el0_svc+0x2c/0x88
    [ 60.331406] el0t_64_sync_handler+0xb8/0xc0
    [ 60.335587] el0t_64_sync+0x18c/0x190
    [ 60.339251] Code: 52800013 d2e00414 35fff45c d503201f (d4210000)
    [ 60.345344] ---[ end trace 0000000000000000 ]---

    To fix it, this patch adds a checking the payload length if it is zero.

    Fixes: 343dc693f7b7 ("misc: pci_endpoint_test: Prevent some integer overflows")
    Cc: stable
    Signed-off-by: Shunsuke Mie
    Link: https://lore.kernel.org/r/20220907020100.122588-2-mie@igel.co.jp
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit e5ebcbb4f967af2083d409271aaf7c7d8351603f)

    Shunsuke Mie
     
  • commit 3e42deaac06567c7e86d287c305ccda24db4ae3d upstream.

    Each transfer test functions have same parameter checking code. This patch
    unites those to an introduced function.

    Signed-off-by: Shunsuke Mie
    Cc: stable
    Link: https://lore.kernel.org/r/20220907020100.122588-1-mie@igel.co.jp
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit cb9defecf381415f6aeb433a05a6c4374775e9d6)

    Shunsuke Mie
     
  • commit a17b9841152e7f4621619902b347e2cc39c32996 upstream.

    Suspending and resuming the system can sometimes cause the out
    URB to get hung after a reset_resume. This causes LED setting
    and force feedback to break on resume. To avoid this, just drop
    the reset_resume callback so the USB core rebinds xpad to the
    wireless pads on resume if a reset happened.

    A nice side effect of this change is the LED ring on wireless
    controllers is now set correctly on system resume.

    Cc: stable@vger.kernel.org
    Fixes: 4220f7db1e42 ("Input: xpad - workaround dead irq_out after suspend/ resume")
    Signed-off-by: Cameron Gutman
    Signed-off-by: Pavel Rojtberg
    Link: https://lore.kernel.org/r/20220818154411.510308-3-rojtberg@gmail.com
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 2c657a0cbd481eda0a6e12c45f55f03d3332223b)

    Cameron Gutman
     
  • commit b382c5e37344883dc97525d05f1f6b788f549985 upstream.

    This is based on multiple commits at https://github.com/paroj/xpad

    Cc: stable@vger.kernel.org
    Signed-off-by: Jasper Poppe
    Signed-off-by: Jeremy Palmer
    Signed-off-by: Ruineka
    Signed-off-by: Cleber de Mattos Casali
    Signed-off-by: Kyle Gospodnetich
    Signed-off-by: Pavel Rojtberg
    Link: https://lore.kernel.org/r/20220818154411.510308-2-rojtberg@gmail.com
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit db4db28fccb47a4476f2ea1fd5ea22da8f6bedde)

    Pavel Rojtberg
     
  • commit c90b93b5b782891ebfda49d4e5da36632fefd5d1 upstream.

    When updating beacon elements in a non-transmitted BSS,
    also update the hidden sub-entries to the same beacon
    elements, so that a future update through other paths
    won't trigger a WARN_ON().

    The warning is triggered because the beacon elements in
    the hidden BSSes that are children of the BSS should
    always be the same as in the parent.

    Reported-by: Sönke Huster
    Tested-by: Sönke Huster
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit d15bb1f6dabe1d2a4155958111bea47db72b599c)

    Johannes Berg
     
  • commit b2d03cabe2b2e150ff5a381731ea0355459be09f upstream.

    If beacon protection is active but the beacon cannot be
    decrypted or is otherwise malformed, we call the cfg80211
    API to report this to userspace, but that uses a netdev
    pointer, which isn't present for P2P-Device. Fix this to
    call it only conditionally to ensure cfg80211 won't crash
    in the case of P2P-Device.

    This fixes CVE-2022-42722.

    Reported-by: Sönke Huster
    Fixes: 9eaf183af741 ("mac80211: Report beacon protection failures to user space")
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 93a3a32554079432b49cf87f326607b2a2fab4f2)

    Johannes Berg
     
  • commit 1833b6f46d7e2830251a063935ab464256defe22 upstream.

    If the tool on the other side (e.g. wmediumd) gets confused
    about the rate, we hit a warning in mac80211. Silence that
    by effectively duplicating the check here and dropping the
    frame silently (in mac80211 it's dropped with the warning).

    Reported-by: Sönke Huster
    Tested-by: Sönke Huster
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit fff244e9171b2ca692469d41c68b36607bd73ab0)

    Johannes Berg
     
  • commit bcca852027e5878aec911a347407ecc88d6fff7f upstream.

    If a non-transmitted BSS shares enough information (both
    SSID and BSSID!) with another non-transmitted BSS of a
    different AP, then we can find and update it, and then
    try to add it to the non-transmitted BSS list. We do a
    search for it on the transmitted BSS, but if it's not
    there (but belongs to another transmitted BSS), the list
    gets corrupted.

    Since this is an erroneous situation, simply fail the
    list insertion in this case and free the non-transmitted
    BSS.

    This fixes CVE-2022-42721.

    Reported-by: Sönke Huster
    Tested-by: Sönke Huster
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 0a8ee682e4f992eccce226b012bba600bb2251e2)

    Johannes Berg
     
  • commit 0b7808818cb9df6680f98996b8e9a439fa7bcc2f upstream.

    There are multiple refcounting bugs related to multi-BSSID:
    - In bss_ref_get(), if the BSS has a hidden_beacon_bss, then
    the bss pointer is overwritten before checking for the
    transmitted BSS, which is clearly wrong. Fix this by using
    the bss_from_pub() macro.

    - In cfg80211_bss_update() we copy the transmitted_bss pointer
    from tmp into new, but then if we release new, we'll unref
    it erroneously. We already set the pointer and ref it, but
    need to NULL it since it was copied from the tmp data.

    - In cfg80211_inform_single_bss_data(), if adding to the non-
    transmitted list fails, we unlink the BSS and yet still we
    return it, but this results in returning an entry without
    a reference. We shouldn't return it anyway if it was broken
    enough to not get added there.

    This fixes CVE-2022-42720.

    Reported-by: Sönke Huster
    Tested-by: Sönke Huster
    Fixes: a3584f56de1c ("cfg80211: Properly track transmitting and non-transmitting BSS")
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit bfe29873454f38eb1a511a76144ad1a4848ca176)

    Johannes Berg
     
  • commit 567e14e39e8f8c6997a1378bc3be615afca86063 upstream.

    When iterating the elements here, ensure the length byte is
    present before checking it to see if the entire element will
    fit into the buffer.

    Longer term, we should rewrite this code using the type-safe
    element iteration macros that check all of this.

    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Reported-by: Soenke Huster
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 9e99ca59ed3976921f8891c103d503b6da3e78af)

    Johannes Berg
     
  • commit 8f033d2becc24aa6bfd2a5c104407963560caabc upstream.

    Per spec, the maximum value for the MaxBSSID ('n') indicator is 8,
    and the minimum is 1 since a multiple BSSID set with just one BSSID
    doesn't make sense (the # of BSSIDs is limited by 2^n).

    Limit this in the parsing in both cfg80211 and mac80211, rejecting
    any elements with an invalid value.

    This fixes potentially bad shifts in the processing of these inside
    the cfg80211_gen_new_bssid() function later.

    I found this during the investigation of CVE-2022-41674 fixed by the
    previous patch.

    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Fixes: 78ac51f81532 ("mac80211: support multi-bssid")
    Reviewed-by: Kees Cook
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 0a861bd25dad508e492c48169509d8c6b9246895)

    Johannes Berg
     
  • commit aebe9f4639b13a1f4e9a6b42cdd2e38c617b442d upstream.

    In the copy code of the elements, we do the following calculation
    to reach the end of the MBSSID element:

    /* copy the IEs after MBSSID */
    cpy_len = mbssid[1] + 2;

    This looks fine, however, cpy_len is a u8, the same as mbssid[1],
    so the addition of two can overflow. In this case the subsequent
    memcpy() will overflow the allocated buffer, since it copies 256
    bytes too much due to the way the allocation and memcpy() sizes
    are calculated.

    Fix this by using size_t for the cpy_len variable.

    This fixes CVE-2022-41674.

    Reported-by: Soenke Huster
    Tested-by: Soenke Huster
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Reviewed-by: Kees Cook
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 9a8ef2030510a9d6ce86fd535b8d10720230811f)

    Johannes Berg
     

07 Nov, 2022

10 commits

  • Up until now, the external MDIO controller frequency values relied
    either on the default ones out of reset or on those setup by u-boot.
    Let's just properly specify the MDC frequency in the DTS so that even
    without u-boot's intervention Linux can drive the MDIO bus.

    Fixes: 0420dde30a90 ("arm64: dts: ls208xa: add the external MDIO nodes")
    Signed-off-by: Ioana Ciornei

    Ioana Ciornei
     
  • Up until now, the external MDIO controller frequency values relied
    either on the default ones out of reset or on those setup by u-boot.
    Let's just properly specify the MDC frequency in the DTS so that even
    without u-boot's intervention Linux can drive the MDIO bus.

    Fixes: bbe75af7b092 ("arm64: dts: ls1088a: add external MDIO device nodes")
    Signed-off-by: Ioana Ciornei

    Ioana Ciornei
     
  • Up until now, the external MDIO controller frequency values relied
    either on the default ones out of reset or on those setup by u-boot.
    Let's just properly specify the MDC frequency in the DTS so that even
    without u-boot's intervention Linux can drive the MDIO bus.

    Fixes: 6e1b8fae892d ("arm64: dts: lx2160a: add emdio1 node")
    Fixes: 5705b9dcda57 ("arm64: dts: lx2160a: add emdio2 node")
    Signed-off-by: Ioana Ciornei

    Ioana Ciornei
     
  • In order to make the underneath API easier to change in the future,
    prevent users from dereferencing fwnode from struct device.
    Instead, use the specific dev_fwnode() API for that.

    Signed-off-by: zhaoxiao
    Signed-off-by: David S. Miller
    (cherry picked from commit 105b0468d7b2e6779a188a83b7e128368acb8a1d)

    zhaoxiao
     
  • When compiling with -Wformat, clang emits the following warning:

    drivers/net/ethernet/freescale/xgmac_mdio.c:243:22: warning: format
    specifies type 'unsigned char' but the argument has type 'int'
    [-Wformat]
    phy_id, dev_addr, regnum);
    ^~~~~~
    ./include/linux/dev_printk.h:163:47: note: expanded from macro 'dev_dbg'
    dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
    ~~~ ^~~~~~~~~~~
    ./include/linux/dev_printk.h:129:34: note: expanded from macro 'dev_printk'
    _dev_printk(level, dev, fmt, ##__VA_ARGS__); \
    ~~~ ^~~~~~~~~~~

    The types of these arguments are unconditionally defined, so this patch
    updates the format character to the correct ones for ints and unsigned
    ints.

    Link: https://github.com/ClangBuiltLinux/linux/issues/378
    Signed-off-by: Bill Wendling
    Link: https://lore.kernel.org/r/20220316213114.2352352-1-morbo@google.com
    Signed-off-by: Jakub Kicinski
    (cherry picked from commit c011072c90353814a9d8e2b3cd111e77ae8601ed)

    Bill Wendling
     
  • In case of error, the function devm_ioremap() returns NULL pointer
    not ERR_PTR(). The IS_ERR() test in the return value check should
    be replaced with NULL test.

    Fixes: 1d14eb15dc2c ("net/fsl: xgmac_mdio: Use managed device resources")
    Reported-by: Hulk Robot
    Signed-off-by: Wei Yongjun
    Reviewed-by: Tobias Waldekranz
    Signed-off-by: David S. Miller
    (cherry picked from commit cc4598cf179ff636d7634008045905a88480bb88)

    Wei Yongjun
     
  • There is a spelling mistake in a dev_err message. Fix it.

    Signed-off-by: Colin Ian King
    Signed-off-by: David S. Miller
    (cherry picked from commit 34a79c5dca4aeabc26073ef36233ea1f409b4d4b)

    Colin Ian King
     
  • Support the standard "clock-frequency" attribute to set the generated
    MDC frequency. If not specified, the driver will leave the divisor
    bits untouched.

    Signed-off-by: Tobias Waldekranz
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller
    (cherry picked from commit dd8f467eda72cdaff50e4636c382709124956da3)

    Tobias Waldekranz
     
  • Support the standard "suppress-preamble" attribute to disable preamble
    generation.

    Signed-off-by: Tobias Waldekranz
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller
    (cherry picked from commit 909bea73485fab5e99e222e727e82b259d667880)

    Tobias Waldekranz
     
  • All of the resources used by this driver has managed interfaces, so
    use them. Heed the warning in the comment before platform_get_resource
    and use a bare devm_ioremap to allow for non-exclusive access to the
    IO memory.

    Signed-off-by: Tobias Waldekranz
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller
    (cherry picked from commit 1d14eb15dc2c3961ffe88d20df17fb2e2eaf1504)

    Tobias Waldekranz
     

03 Nov, 2022

2 commits

  • lx2160ardb and lx2162aqds failed to read out thermal zone when using
    Linux 5.15.71-lf-5.15.52-2.1.0-2798-g393a61ecb9db. This is because the
    IPBRR0s of lx2160ardb, lx2162aqds and i.MX93 have the same value
    0x01900201. It is wrong to use IPBRR0 to determine whether the current
    TMU belongs to i.MX93 or not, so that change to use compatible.

    Signed-off-by: Alice Guo
    Reviewed-by: Ye Li
    Acked-by: Jason Liu

    Alice Guo
     
  • LPUART only support the system wakeup when the UART clock on, but on
    imx93, system mem suspend will shut-off the UART clocks, cause the
    system cannot be waken up.
    So need to add asynchronous wakeup support for LPUART in Low-Power mode,
    now LPUART does not need any clocks to wake-up the Arm platform with the
    asynchronous interrupts.

    Signed-off-by: Sherry Sun
    Reviewed-by: Jacky Bai
    Acked-by: Jason Liu

    Sherry Sun
     

26 Oct, 2022

15 commits

  • Enable support for XDP (supported on DPAA1, DPAA2, ENETC) and for AF_XDP
    (supported on DPAA2, ENETC).

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Add support for the case when the BPF program attached to a ring with an
    XSK pool returns the XDP_TX verdict. The frame needs to go back on the
    interface it came from.

    No dma_map or dma_sync_for_device is necessary, just a small impedance
    matching logic with the XDP_TX procedure we have in place for non-XSK,
    since the data structures are different (xdp_buff vs xdp_frame; cannot
    have multi-buffer with XSK).

    In the TX confirmation routine, just release the RX buffer (as opposed
    to non-XSK XDP_TX). Recycling might be possible, but I haven't
    experimented with it.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Schedule NAPI by hand from enetc_xsk_wakeup(), and send frames from the
    XSK TX queue from NAPI context. Add them to the completion queue from
    the enetc_clean_tx_ring() procedure which is common for all kinds of
    traffic.

    We reuse one of the TX rings for XDP (XDP_TX/XDP_REDIRECT) for XSK as
    well. They are already affine with CPUs and cropped from the TX rings
    that the network stack can use when XDP is enabled (with or without
    AF_XDP).

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Add support for filling an RX ring with buffers coming from an XSK umem.
    Although enetc has up to 8 RX rings, we still use one of the 2 per-CPU
    RX rings for XSK.

    To set up an XSK pool on one of the RX queues, we stop the device and
    open it again. While not ideal, the alternative would have been way more
    complex.

    Since the RX procedure in the NAPI poll function is completely different
    (both the API for creating an xdp_buff, as well as refilling the ring
    with memory from user space), create a separate enetc_clean_rx_ring_xsk()
    function which gets called when we have both an XSK pool and an XDK
    program on this RX queue.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • XSK transmission will reuse this procedure, and will also need the logic
    for setting the "final" bit of a TX BD, based on tx_swbd->is_eof.
    Not sure why this was left to be done by the caller of
    enetc_xdp_map_tx_buff(), but move it inside.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • napi_synchronize() from enetc_stop() waits until the softirq has
    finished execution and does not reschedule anymore. However under high
    traffic load, this will never happen, and the interface can never be
    closed.

    The solution chosen here is probably not the best; it is adapted from
    i40e. Normally one would quiesce the RX ring and let the softirq finish
    what remains there. But I couldn't immediately see how to do that (plus
    the fact that the NAPI poll routine is written to update the consumer
    index which makes the device want to put more buffers in the RX ring,
    which restarts the madness again).

    Since the enetc hardirq may trigger while we have ENETC_DOWN set, it may
    happen that enetc_msix() masks it, but enetc_poll() never unmasks it.
    To prevent a stall in that case, schedule all NAPI instances when
    ENETC_DOWN gets cleared.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • v->rx_ring.stats.bytes is apparently only used for interrupt coalescing,
    not for printing to ethtool -S. I am unable to find a functional problem
    caused by the lack of updating this counter, but it is updated from the
    stack NAPI poll routine, so update it from the XDP one too.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Create naming consistency between the free procedures for a TX and an RX
    software BD.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • There are multiple code paths in the driver which DMA unmap and free the
    page held by the shadow copy of an RX buffer descriptor. Refactor them
    to call the same helper function, which will make it easier to add
    support for one more RX software BD type in the future (XSK buffer).

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • In a strange twist of events, some libraries such as libbpf perform an
    ETHTOOL_GCHANNELS ioctl to find out the max number of queues a device
    has, number which in turn is used for attaching XDP sockets to queues.

    To add compatibility with libbpf, it is therefore desirable to report
    something to this ethtool callback.

    According to the ethtool man page, "A channel is an IRQ and the set of
    queues that can trigger that IRQ".

    In enetc (embedded in NXP LS1028A, a dual core SoC, and LS1018A, a
    single core SoC), the enetc_alloc_msix() function allocates a number of
    MSI-X interrupt vectors equal to priv->bdr_int_num (which in turn is
    equal to the number of CPUs, 2 or 1). Each interrupt vector has 1 RX
    ring to process (there are more than 2 RX rings available on an ENETC
    port, but the driver only uses up to 2). In addition, the up to 8 TX
    rings are distributed in a round-robing manner between the up to 2
    available interrupt vectors.

    Therefore, even if we have more resources than 2 RX rings, given the
    definitions, we can only report 2 combined channels. So do that.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • If we see frames with RX errors, consume them, mark their buffers for
    refill, and go through the rest of the ring until the NAPI budget is
    done. Right now we exit and ask the softirq to be rescheduled.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Calling enetc_bd_unused() on an RX ring returns the number of
    descriptors necessary for the ring to be full with descriptors owned by
    hardware (for it to put packets in).

    Putting this value in a variable named "cleaned_cnt" is misleading,
    especially since we may start the NAPI poll routine (enetc_clean_rx_ring)
    with a non-zero cleaned_cnt.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • In a future patch, the XDP RX queues will have to register a shared page
    memory model, or an XSK pool memory model. For that, the registration
    needs to be more dynamic than the current one, done in enetc_pf_probe()
    -> enetc_alloc_msix().

    Move it to enetc_open()/enetc_close() and create some nicer names for
    it.

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Follow the convention from this driver, which is to name "struct
    net_device *" as "ndev", and the convention from other drivers, to name
    "struct netdev_bpf *" as "bpf".

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean
     
  • Eliminate a 4 byte hole on arm64, to be able to introduce a new member
    to this structure in a future patch without increasing the overall
    structure size.

    Before:

    struct enetc_rx_swbd {
    struct page * page; /* 0 8 */
    enum dma_data_direction dir; /* 8 4 */

    /* XXX 4 bytes hole, try to pack */

    dma_addr_t dma; /* 16 8 */
    u16 page_offset; /* 24 2 */
    u16 len; /* 26 2 */

    /* size: 32, cachelines: 1, members: 5 */
    /* sum members: 24, holes: 1, sum holes: 4 */
    /* padding: 4 */
    /* last cacheline: 32 bytes */
    };

    After:

    struct enetc_rx_swbd {
    struct page * page; /* 0 8 */
    dma_addr_t dma; /* 8 8 */
    enum dma_data_direction dir; /* 16 4 */
    u16 page_offset; /* 20 2 */
    u16 len; /* 22 2 */

    /* size: 24, cachelines: 1, members: 5 */
    /* last cacheline: 24 bytes */
    };

    Signed-off-by: Vladimir Oltean

    Vladimir Oltean