1. 30 May, 2019 40 commits
    • David S. Miller's avatar
      Merge branch 'connection-tracking-support-for-bridge' · 41384136
      David S. Miller authored
      Pablo Neira Ayuso says:
      
      ====================
      connection tracking support for bridge
      
      This patchset adds native connection tracking support for the bridge.
      
      Patch #1 and #2 extract code from IPv4/IPv6 fragmentation core and
      introduce the fraglist splitter. That splits a skbuff fraglist into
      independent fragments.
      
      Patch #3 and #4 also extract code from IPv4/IPv6 fragmentation core
      and introduce the skbuff into fragments transformer. This can be used
      by linearized skbuffs (eg. coming from nfqueue and ct helpers) as well
      as cloned skbuffs (that are either seen either with taps or with bridge
      port flooding).
      
      Patch #5 moves the specific IPCB() code from these new fragment
      splitter/transformer APIs into the IPv4 stack. The bridge has a
      different control buffer layout and it starts using this new APIs in
      this patchset.
      
      Patch #6 adds basic infrastructure that allows to register bridge
      conntrack support.
      
      Patch #7 adds bridge conntrack support (only for IPv4 in this patch).
      
      Patch #8 adds IPv6 support for the bridge conntrack support.
      
      Patch #9 registers the IPv4/IPv6 conntrack hooks in case the bridge
      conntrack is used to deal with local traffic, ie. prerouting -> input
      bridge hook path. This cover the bridge interface has a IP address
      scenario.
      
      Before this patchset, only chance for people to do stateful filtering is
      to use the `br_netfilter` emulation layer, that turns bridge frame into
      IPv4/IPv6 packets and inject them into the IPv4/IPv6 hooks. Apparently,
      this module allows users to use iptables and all of its feature-set from
      the bridge, including stateful filtering. However, this approach is
      flawed in many aspects that have been discussed many times. This is a
      step forward to deprecate `br_netfilter'.
      
      v2: Fix English typo in commit message.
      v3: Fix another English typo in commit message.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      41384136
    • Pablo Neira Ayuso's avatar
      netfilter: nf_conntrack_bridge: register inet conntrack for bridge · af9573be
      Pablo Neira Ayuso authored
      This patch enables IPv4 and IPv6 conntrack from the bridge to deal with
      local traffic. Hence, packets that are passed up to the local input path
      are confirmed later on from the {ipv4,ipv6}_confirm() hooks.
      
      For packets leaving the IP stack (ie. output path), fragmentation occurs
      after the inet postrouting hook. Therefore, the bridge local out and
      postrouting bridge hooks see fragments with conntrack objects, which is
      inconsistent. In this case, we could defragment again from the bridge
      output hook, but this is expensive. The recommended filtering spot for
      outgoing locally generated traffic leaving through the bridge interface
      is to use the classic IPv4/IPv6 output hook, which comes earlier.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      af9573be
    • Pablo Neira Ayuso's avatar
      netfilter: nf_conntrack_bridge: add support for IPv6 · 764dd163
      Pablo Neira Ayuso authored
      br_defrag() and br_fragment() indirections are added in case that IPv6
      support comes as a module, to avoid pulling innecessary dependencies in.
      
      The new fraglist iterator and fragment transformer APIs are used to
      implement the refragmentation code.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      764dd163
    • Pablo Neira Ayuso's avatar
      netfilter: bridge: add connection tracking system · 3c171f49
      Pablo Neira Ayuso authored
      This patch adds basic connection tracking support for the bridge,
      including initial IPv4 support.
      
      This patch register two hooks to deal with the bridge forwarding path,
      one from the bridge prerouting hook to call nf_conntrack_in(); and
      another from the bridge postrouting hook to confirm the entry.
      
      The conntrack bridge prerouting hook defragments packets before passing
      them to nf_conntrack_in() to look up for an existing entry, otherwise a
      new entry is allocated and it is attached to the skbuff. The conntrack
      bridge postrouting hook confirms new conntrack entries, ie. if this is
      the first packet seen, then it adds the entry to the hashtable and (if
      needed) it refragments the skbuff into the original fragments, leaving
      the geometry as is if possible. Exceptions are linearized skbuffs, eg.
      skbuffs that are passed up to nfqueue and conntrack helpers, as well as
      cloned skbuff for the local delivery (eg. tcpdump), also in case of
      bridge port flooding (cloned skbuff too).
      
      The packet defragmentation is done through the ip_defrag() call.  This
      forces us to save the bridge control buffer, reset the IP control buffer
      area and then restore it after call. This function also bumps the IP
      fragmentation statistics, it would be probably desiderable to have
      independent statistics for the bridge defragmentation/refragmentation.
      The maximum fragment length is stored in the control buffer and it is
      used to refragment the skbuff from the postrouting path.
      
      The new fraglist splitter and fragment transformer APIs are used to
      implement the bridge refragmentation code. The br_ip_fragment() function
      drops the packet in case the maximum fragment size seen is larger than
      the output port MTU.
      
      This patchset follows the principle that conntrack should not drop
      packets, so users can do it through policy via invalid state matching.
      
      Like br_netfilter, there is no refragmentation for packets that are
      passed up for local delivery, ie. prerouting -> input path. There are
      calls to nf_reset() already in several spots in the stack since time ago
      already, eg. af_packet, that show that skbuff fraglist handling from the
      netif_rx path is supported already.
      
      The helpers are called from the postrouting hook, before confirmation,
      from there we may see packet floods to bridge ports. Then, although
      unlikely, this may result in exercising the helpers many times for each
      clone. It would be good to explore how to pass all the packets in a list
      to the conntrack hook to do this handle only once for this case.
      
      Thanks to Florian Westphal for handing me over an initial patchset
      version to add support for conntrack bridge.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3c171f49
    • Pablo Neira Ayuso's avatar
      netfilter: nf_conntrack: allow to register bridge support · d035f19f
      Pablo Neira Ayuso authored
      This patch adds infrastructure to register and to unregister bridge
      support for the conntrack module via nf_ct_bridge_register() and
      nf_ct_bridge_unregister().
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d035f19f
    • Pablo Neira Ayuso's avatar
      net: ipv4: place control buffer handling away from fragmentation iterators · 19c3401a
      Pablo Neira Ayuso authored
      Deal with the IPCB() area away from the iterators.
      
      The bridge codebase has its own control buffer layout, move specific
      IP control buffer handling into the IPv4 codepath.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      19c3401a
    • Pablo Neira Ayuso's avatar
      net: ipv6: split skbuff into fragments transformer · 8a6a1f17
      Pablo Neira Ayuso authored
      This patch exposes a new API to refragment a skbuff. This allows you to
      split either a linear skbuff or to force the refragmentation of an
      existing fraglist using a different mtu. The API consists of:
      
      * ip6_frag_init(), that initializes the internal state of the transformer.
      * ip6_frag_next(), that allows you to fetch the next fragment. This function
        internally allocates the skbuff that represents the fragment, it pushes
        the IPv6 header, and it also copies the payload for each fragment.
      
      The ip6_frag_state object stores the internal state of the splitter.
      
      This code has been extracted from ip6_fragment(). Symbols are also
      exported to allow to reuse this iterator from the bridge codepath to
      build its own refragmentation routine by reusing the existing codebase.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8a6a1f17
    • Pablo Neira Ayuso's avatar
      net: ipv4: split skbuff into fragments transformer · 065ff79f
      Pablo Neira Ayuso authored
      This patch exposes a new API to refragment a skbuff. This allows you to
      split either a linear skbuff or to force the refragmentation of an
      existing fraglist using a different mtu. The API consists of:
      
      * ip_frag_init(), that initializes the internal state of the transformer.
      * ip_frag_next(), that allows you to fetch the next fragment. This function
        internally allocates the skbuff that represents the fragment, it pushes
        the IPv4 header, and it also copies the payload for each fragment.
      
      The ip_frag_state object stores the internal state of the splitter.
      
      This code has been extracted from ip_do_fragment(). Symbols are also
      exported to allow to reuse this iterator from the bridge codepath to
      build its own refragmentation routine by reusing the existing codebase.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      065ff79f
    • Pablo Neira Ayuso's avatar
      net: ipv6: add skbuff fraglist splitter · 0feca619
      Pablo Neira Ayuso authored
      This patch adds the skbuff fraglist split iterator. This API provides an
      iterator to transform the fraglist into single skbuff objects, it
      consists of:
      
      * ip6_fraglist_init(), that initializes the internal state of the
        fraglist iterator.
      * ip6_fraglist_prepare(), that restores the IPv6 header on the fragment.
      * ip6_fraglist_next(), that retrieves the fragment from the fraglist and
        updates the internal state of the iterator to point to the next
        fragment in the fraglist.
      
      The ip6_fraglist_iter object stores the internal state of the iterator.
      
      This code has been extracted from ip6_fragment(). Symbols are also
      exported to allow to reuse this iterator from the bridge codepath to
      build its own refragmentation routine by reusing the existing codebase.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0feca619
    • Pablo Neira Ayuso's avatar
      net: ipv4: add skbuff fraglist splitter · c8b17be0
      Pablo Neira Ayuso authored
      This patch adds the skbuff fraglist splitter. This API provides an
      iterator to transform the fraglist into single skbuff objects, it
      consists of:
      
      * ip_fraglist_init(), that initializes the internal state of the
        fraglist splitter.
      * ip_fraglist_prepare(), that restores the IPv4 header on the
        fragments.
      * ip_fraglist_next(), that retrieves the fragment from the fraglist and
        it updates the internal state of the splitter to point to the next
        fragment skbuff in the fraglist.
      
      The ip_fraglist_iter object stores the internal state of the iterator.
      
      This code has been extracted from ip_do_fragment(). Symbols are also
      exported to allow to reuse this iterator from the bridge codepath to
      build its own refragmentation routine by reusing the existing codebase.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c8b17be0
    • David S. Miller's avatar
      Merge branch 'add-TFO-backup-key' · d48ecb40
      David S. Miller authored
      Jason Baron says:
      
      ====================
      add TFO backup key
      
      Christoph, Igor, and I have worked on an API that facilitates TFO key
      rotation. This is a follow up to the series that Christoph previously
      posted, with an API that meets both of our use-cases. Here's a
      link to the previous work:
      https://patchwork.ozlabs.org/cover/1013753/
      
      Changes in v2:
        -spelling fixes in ip-sysctl.txt (Jeremy Sowden)
        -re-base to latest net-next
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d48ecb40
    • Jason Baron's avatar
      selftests/net: add TFO key rotation selftest · 10fbcdd1
      Jason Baron authored
      Demonstrate how the primary and backup TFO keys can be rotated while
      minimizing the number of client cookies that are rejected.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      10fbcdd1
    • Jason Baron's avatar
      Documentation: ip-sysctl.txt: Document tcp_fastopen_key · 2dc7e48d
      Jason Baron authored
      Add docs for /proc/sys/net/ipv4/tcp_fastopen_key
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Cc: Jeremy Sowden <jeremy@azazel.net>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2dc7e48d
    • Jason Baron's avatar
      tcp: add support for optional TFO backup key to net.ipv4.tcp_fastopen_key · aa1236cd
      Jason Baron authored
      Add the ability to add a backup TFO key as:
      
      # echo "x-x-x-x,x-x-x-x" > /proc/sys/net/ipv4/tcp_fastopen_key
      
      The key before the comma acks as the primary TFO key and the key after the
      comma is the backup TFO key. This change is intended to be backwards
      compatible since if only one key is set, userspace will simply read back
      that single key as follows:
      
      # echo "x-x-x-x" > /proc/sys/net/ipv4/tcp_fastopen_key
      # cat /proc/sys/net/ipv4/tcp_fastopen_key
      x-x-x-x
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aa1236cd
    • Jason Baron's avatar
      tcp: add support to TCP_FASTOPEN_KEY for optional backup key · 0f1ce023
      Jason Baron authored
      Add support for get/set of an optional backup key via TCP_FASTOPEN_KEY, in
      addition to the current 'primary' key. The primary key is used to encrypt
      and decrypt TFO cookies, while the backup is only used to decrypt TFO
      cookies. The backup key is used to maximize successful TFO connections when
      TFO keys are rotated.
      
      Currently, TCP_FASTOPEN_KEY allows a single 16-byte primary key to be set.
      This patch now allows a 32-byte value to be set, where the first 16 bytes
      are used as the primary key and the second 16 bytes are used for the backup
      key. Similarly, for getsockopt(), we can receive a 32-byte value as output
      if requested. If a 16-byte value is used to set the primary key via
      TCP_FASTOPEN_KEY, then any previously set backup key will be removed.
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0f1ce023
    • Jason Baron's avatar
      tcp: add backup TFO key infrastructure · 9092a76d
      Jason Baron authored
      We would like to be able to rotate TFO keys while minimizing the number of
      client cookies that are rejected. Currently, we have only one key which can
      be used to generate and validate cookies, thus if we simply replace this
      key clients can easily have cookies rejected upon rotation.
      
      We propose having the ability to have both a primary key and a backup key.
      The primary key is used to generate as well as to validate cookies.
      The backup is only used to validate cookies. Thus, keys can be rotated as:
      
      1) generate new key
      2) add new key as the backup key
      3) swap the primary and backup key, thus setting the new key as the primary
      
      We don't simply set the new key as the primary key and move the old key to
      the backup slot because the ip may be behind a load balancer and we further
      allow for the fact that all machines behind the load balancer will not be
      updated simultaneously.
      
      We make use of this infrastructure in subsequent patches.
      Suggested-by: default avatarIgor Lubashev <ilubashe@akamai.com>
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9092a76d
    • Christoph Paasch's avatar
      tcp: introduce __tcp_fastopen_cookie_gen_cipher() · 483642e5
      Christoph Paasch authored
      Restructure __tcp_fastopen_cookie_gen() to take a 'struct crypto_cipher'
      argument and rename it as __tcp_fastopen_cookie_gen_cipher(). Subsequent
      patches will provide different ciphers based on which key is being used for
      the cookie generation.
      Signed-off-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Signed-off-by: default avatarJason Baron <jbaron@akamai.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      483642e5
    • David S. Miller's avatar
      Merge branch 'mlxsw-Hardware-monitoring-enhancements' · 5b5d331a
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      mlxsw: Hardware monitoring enhancements
      
      This patchset from Vadim provides various hardware monitoring related
      improvements for mlxsw.
      
      Patch #1 allows querying firmware version from the switch driver when
      the underlying bus is I2C. This is useful for baseboard management
      controller (BMC) systems that communicate with the ASIC over I2C.
      
      Patch #2 improves driver's performance over I2C by utilizing larger
      transactions sizes, if possible.
      
      Patch #3 re-orders driver's initialization sequence to enforce a
      specific firmware version before new firmware features are utilized.
      This is a prerequisite for patches #4-#6.
      
      Patches #4-#6 expose the temperature of inter-connect devices
      (gearboxes) that are present in Mellanox SN3800 systems and split
      2x50Gb/s lanes to 4x25Gb/s lanes.
      
      Patches #7-#8 reduce the transaction size when reading SFP modules
      temperatures, which is crucial when working over I2C.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5b5d331a
    • Vadim Pasternak's avatar
      mlxsw: core: Reduce buffer size in transactions for SFP modules temperature readout · e4e93d6d
      Vadim Pasternak authored
      Obtain SFP modules temperatures through MTMP register instead of MTBR
      register, because the first one utilizes shorter transaction buffer size
      for request. It improves performance in case low frequency interface
      (I2C) is used for communication with a chip.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4e93d6d
    • Vadim Pasternak's avatar
      mlxsw: core: Extend the index size for temperature sensors readout · 984aec75
      Vadim Pasternak authored
      Extend sensor index size for Management Temperature Bulk Register
      (MTBR) and Management Temperature Register (MTMP) upto 12 bits in
      order to align registers description with new version of PRM document.
      Add define for base sensor index for SFP modules temperature reading
      for MTMP register.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      984aec75
    • Vadim Pasternak's avatar
      mlxsw: core: Extend hwmon interface with inter-connect temperature attributes · 2e265a8b
      Vadim Pasternak authored
      Add new attributes to hwmon object for exposing inter-connects temperature
      input, highest, reset_history temperatures and label. Temperatures are read
      from Management Temperature Register.
      The number of inter-connect devices is read from Management General
      Peripheral Information Register.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2e265a8b
    • Vadim Pasternak's avatar
      mlxsw: reg: Add Management General Peripheral Information Register · 7e9561ed
      Vadim Pasternak authored
      Add MGPIR - Management General Peripheral Information Register, which
      allows software to query the hardware and firmware general information
      of peripheral entities as Gearboxes etc.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7e9561ed
    • Vadim Pasternak's avatar
      mlxsw: reg: Extend sensor index field size of Management Temperature Register · ae574678
      Vadim Pasternak authored
      Extend the size of sensor_index field of MTMP (Management Temperature
      Register), from 8 to 12 bits due to hardware change.
      Add define for sensor index for Gear Box (inter-connects) temperature
      reading.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ae574678
    • Ido Schimmel's avatar
      mlxsw: core: Re-order initialization sequence · 961cf99a
      Ido Schimmel authored
      The driver core first registers with the hwmon and thermal subsystems
      and only then proceeds to initialize the switch driver (e.g.,
      mlxsw_spectrum). It is only during the last stage that the current
      firmware version is validated and a newer one flashed, if necessary.
      
      The above means that if a new firmware feature is utilized by the
      hwmon/thermal code, the driver will not be able to load.
      
      Solve this by re-ordering initializing the switch driver before
      registering with the hwmon and thermal subsystems.
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Reported-by: default avatarShalom Toledo <shalomt@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      961cf99a
    • Vadim Pasternak's avatar
      mlxsw: i2c: Allow flexible setting of I2C transactions size · 3029a693
      Vadim Pasternak authored
      Current implementation uses fixed size of I2C data transaction buffer.
      Allow to set size of I2C transactions according to I2C physical adapter
      capability. For that purpose adapter read and write size is obtained
      from the I2C physical adapter and buffer size is set according to the
      minimum of these two values. If adapter does not provide such info,
      default buffer size is to be used.
      It allows to improve performance of I2C access to silicon when long
      size transactions are used.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3029a693
    • Vadim Pasternak's avatar
      mlxsw: i2c: Extend initialization with querying firmware info · 9bbd7efb
      Vadim Pasternak authored
      Extend initialization flow with query request for firmware info in
      order to obtain firmware version info.
      This info is to be provided to minimal driver to support ethtool
      get_drvinfo() interface.
      Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9bbd7efb
    • David S. Miller's avatar
      Merge branch 'net-stmmac-selftests-Two-fixes' · 18a49727
      David S. Miller authored
      Jose Abreu says:
      
      ====================
      net: stmmac: selftests: Two fixes
      
      Two fixes reported by kbuild.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      18a49727
    • Jose Abreu's avatar
      net: stmmac: selftests: Use kfree_skb() instead of kfree() · aeb4a5e8
      Jose Abreu authored
      kfree_skb() shall be used instead of kfree(). Fix it.
      
      Fixes: 091810db ("net: stmmac: Introduce selftests support")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Cc: Joao Pinto <jpinto@synopsys.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
      Cc: Alexandre Torgue <alexandre.torgue@st.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aeb4a5e8
    • Jose Abreu's avatar
      net: stmmac: selftests: Fix sparse warning · 2d135dea
      Jose Abreu authored
      Variable shall be __be16. Fix it.
      
      Fixes: 091810db ("net: stmmac: Introduce selftests support")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
      Cc: Joao Pinto <jpinto@synopsys.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
      Cc: Alexandre Torgue <alexandre.torgue@st.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2d135dea
    • Herbert Xu's avatar
      inet: frags: Remove unnecessary smp_store_release/READ_ONCE · 32707c4d
      Herbert Xu authored
      The smp_store_release call in fqdir_exit cannot protect the setting
      of fqdir->dead as claimed because its memory barrier is only
      guaranteed to be one-way and the barrier precedes the setting of
      fqdir->dead.
      
      IOW it doesn't provide any barriers between fq->dir and the following
      hash table destruction.
      
      In fact, the code is safe anyway because call_rcu does provide both
      the memory barrier as well as a guarantee that when the destruction
      work starts executing all RCU readers will see the updated value for
      fqdir->dead.
      
      Therefore this patch removes the unnecessary smp_store_release call
      as well as the corresponding READ_ONCE on the read-side in order to
      not confuse future readers of this code.  Comments have been added
      in their places.
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32707c4d
    • YueHaibing's avatar
      net: mvpp2: cls: Remove unnessesary check in mvpp2_ethtool_cls_rule_ins · 5080e28d
      YueHaibing authored
      Fix smatch warning:
      
      drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c:1236
       mvpp2_ethtool_cls_rule_ins() warn: unsigned 'info->fs.location' is never less than zero.
      
      'info->fs.location' is u32 type, never less than zero.
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5080e28d
    • Jisheng Zhang's avatar
      net: stmmac: Switch to devm_alloc_etherdev_mqs · 9737070c
      Jisheng Zhang authored
      Make use of devm_alloc_etherdev_mqs() to simplify the code.
      Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9737070c
    • David S. Miller's avatar
      tua6100: Avoid build warnings. · 621ccc6c
      David S. Miller authored
      Rename _P to _P_VAL and _R to _R_VAL to avoid global
      namespace conflicts:
      
      drivers/media/dvb-frontends/tua6100.c: In function ‘tua6100_set_params’:
      drivers/media/dvb-frontends/tua6100.c:79: warning: "_P" redefined
       #define _P 32
      
      In file included from ./include/acpi/platform/aclinux.h:54,
                       from ./include/acpi/platform/acenv.h:152,
                       from ./include/acpi/acpi.h:22,
                       from ./include/linux/acpi.h:34,
                       from ./include/linux/i2c.h:17,
                       from drivers/media/dvb-frontends/tua6100.h:30,
                       from drivers/media/dvb-frontends/tua6100.c:32:
      ./include/linux/ctype.h:14: note: this is the location of the previous definition
       #define _P 0x10 /* punct */
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      621ccc6c
    • David S. Miller's avatar
      Merge branch 'Enable-SFP-on-ACPI-based-systems' · 3b87cc6f
      David S. Miller authored
      Ruslan Babayev says:
      
      ====================
      Enable SFP on ACPI based systems
      
      Changes:
      v2:
      	- more descriptive commit body
      v3:
      	- made 'i2c_acpi_find_adapter_by_handle' static inline
      v4:
      	- don't initialize i2c_adapter to NULL. Instead see below...
      	- handle the case of neither DT nor ACPI present as invalid.
      	- alphabetical includes.
      	- use has_acpi_companion().
      	- use the same argument name in i2c_acpi_find_adapter_by_handle()
      	  in both stubbed and non-stubbed cases.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3b87cc6f
    • Ruslan Babayev's avatar
      net: phy: sfp: enable i2c-bus detection on ACPI based systems · 7ce236fa
      Ruslan Babayev authored
      Lookup I2C adapter using the "i2c-bus" device property on ACPI based
      systems similar to how it's done with DT.
      
      An example DSD describing an SFP on an ACPI based system:
      
      Device (SFP0)
      {
          Name (_HID, "PRP0001")
          Name (_CRS, ResourceTemplate()
          {
              GpioIo(Exclusive, PullDefault, 0, 0, IoRestrictionNone,
                     "\\_SB.PCI0.RP01.GPIO", 0, ResourceConsumer)
                  { 0, 1, 2, 3, 4 }
          })
          Name (_DSD, Package ()
          {
              ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
              Package () {
                  Package () { "compatible", "sff,sfp" },
                  Package () { "i2c-bus", \_SB.PCI0.RP01.I2C.MUX.CH0 },
                  Package () { "maximum-power-milliwatt", 1000 },
                  Package () { "tx-disable-gpios", Package () { ^SFP0, 0, 0, 1} },
                  Package () { "reset-gpio",       Package () { ^SFP0, 0, 1, 1} },
                  Package () { "mod-def0-gpios",   Package () { ^SFP0, 0, 2, 1} },
                  Package () { "tx-fault-gpios",   Package () { ^SFP0, 0, 3, 0} },
                  Package () { "los-gpios",        Package () { ^SFP0, 0, 4, 1} },
              },
          })
      }
      
      Device (PHY0)
      {
          Name (_HID, "PRP0001")
          Name (_DSD, Package ()
          {
              ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
              Package () {
                  Package () { "compatible", "ethernet-phy-ieee802.3-c45" },
                  Package () { "sfp", \_SB.PCI0.RP01.SFP0 },
                  Package () { "managed", "in-band-status" },
                  Package () { "phy-mode", "sgmii" },
              },
          })
      }
      Signed-off-by: default avatarRuslan Babayev <ruslan@babayev.com>
      Cc: xe-linux-external@cisco.com
      Acked-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7ce236fa
    • Ruslan Babayev's avatar
      i2c: acpi: export i2c_acpi_find_adapter_by_handle · 1e91a2e5
      Ruslan Babayev authored
      This allows drivers to lookup i2c adapters on ACPI based systems similar to
      of_get_i2c_adapter_by_node() with DT based systems.
      Signed-off-by: default avatarRuslan Babayev <ruslan@babayev.com>
      Cc: xe-linux-external@cisco.com
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1e91a2e5
    • Marek Vasut's avatar
      net: phy: tja11xx: Switch to HWMON_CHANNEL_INFO() · 517f4c49
      Marek Vasut authored
      The HWMON_CHANNEL_INFO macro simplifies the code, reduces the likelihood
      of errors, and makes the code easier to read.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Heiner Kallweit <hkallweit1@gmail.com>
      Cc: Jean Delvare <jdelvare@suse.com>
      Cc: linux-hwmon@vger.kernel.org
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      517f4c49
    • Ivan Khoronzhuk's avatar
      net: ethernet: ti: cpsw: correct .ndo_open error path · 02cacede
      Ivan Khoronzhuk authored
      It's found while review and probably never happens, but real number
      of queues is set per device, and error path should be per device.
      So split error path based on usage_count.
      Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      02cacede
    • David S. Miller's avatar
      Merge branch 'Decoupling-PHYLINK-from-struct-net_device' · 6faaffb3
      David S. Miller authored
      Ioana Ciornei says:
      
      ====================
      Decoupling PHYLINK from struct net_device
      
      Following two separate discussion threads in:
        https://www.spinics.net/lists/netdev/msg569087.html
      and:
        https://www.spinics.net/lists/netdev/msg570450.html
      
      Previous RFC patch set: https://www.spinics.net/lists/netdev/msg571995.html
      
      PHYLINK was reworked in order to accept multiple operation types,
      PHYLINK_NETDEV and PHYLINK_DEV, passed through a phylink_config
      structure alongside the corresponding struct device.
      
      One of the main concerns expressed in the RFC was that using notifiers
      to signal the corresponding phylink_mac_ops would break PHYLINK's API
      unity and that it would become harder to grep for its users.
      Using the current approach, we maintain a common API for all users.
      Also, printing useful information in PHYLINK, when decoupled from a
      net_device, is achieved using dev_err&co on the struct device received
      (in DSA's case is the device corresponding to the dsa_switch).
      
      PHYLIB (which PHYLINK uses) was reworked to the extent that it does not
      crash when connecting to a PHY and the net_device pointer is NULL.
      
      Lastly, DSA has been reworked in its way that it handles PHYs for ports
      that lack a net_device (CPU and DSA ports).  For these, it was
      previously using PHYLIB and is now using the PHYLINK_DEV operation type.
      Previously, a driver that wanted to support PHY operations on CPU/DSA
      ports has to implement .adjust_link(). This patch set not only gives
      drivers the options to use PHYLINK uniformly but also urges them to
      convert to it. For compatibility, the old code is kept but it will be
      removed once all drivers switch over.
      
      The patchset was tested on the NXP LS1021A-TSN board having the
      following Ethernet layout:
        https://lkml.org/lkml/2019/5/5/279
      The CPU port was moved from the internal RGMII fixed-link (enet2 ->
      switch port 4) to an external loopback Cat5 cable between the enet1 port
      and the front-facing swp2 SJA1105 port. In this mode, both the master
      and the CPU port have an attached PHY which detects link change events:
      
      [   49.105426] fsl-gianfar soc:ethernet@2d50000 eth1: Link is Down
      [   50.305486] sja1105 spi0.1: Link is Down
      [   53.265596] fsl-gianfar soc:ethernet@2d50000 eth1: Link is Up - 1Gbps/Full - flow control off
      [   54.466304] sja1105 spi0.1: Link is Up - 1Gbps/Full - flow control off
      
      Changes in v2:
        - fixed sparse warnings
        - updated 'Documentation/ABI/testing/sysfs-class-net-phydev'
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6faaffb3
    • Vladimir Oltean's avatar
      net: dsa: sja1105: Fix broken fixed-link interfaces on user ports · af7cd036
      Vladimir Oltean authored
      PHYLIB and PHYLINK handle fixed-link interfaces differently. PHYLIB
      wraps them in a software PHY ("pseudo fixed link") phydev construct such
      that .adjust_link driver callbacks see an unified API. Whereas PHYLINK
      simply creates a phylink_link_state structure and passes it to
      .mac_config.
      
      At the time the driver was introduced, DSA was using PHYLIB for the
      CPU/cascade ports (the ones with no net devices) and PHYLINK for
      everything else.
      
      As explained below:
      
      commit aab9c406
      Author: Florian Fainelli <f.fainelli@gmail.com>
      Date:   Thu May 10 13:17:36 2018 -0700
      
        net: dsa: Plug in PHYLINK support
      
        Drivers that utilize fixed links for user-facing ports (e.g: bcm_sf2)
        will need to implement phylink_mac_ops from now on to preserve
        functionality, since PHYLINK *does not* create a phy_device instance
        for fixed links.
      
      In the above patch, DSA guards the .phylink_mac_config callback against
      a NULL phydev pointer.  Therefore, .adjust_link is not called in case of
      a fixed-link user port.
      
      This patch fixes the situation by converting the driver from using
      .adjust_link to .phylink_mac_config.  This can be done now in a unified
      fashion for both slave and CPU/cascade ports because DSA now uses
      PHYLINK for all ports.
      Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      af7cd036