1. 07 Feb, 2017 40 commits
    • Florian Fainelli's avatar
      net: mv643xx_eth: Do not clobber PHY link outside of state machine · 1105a2d3
      Florian Fainelli authored
      Calling phy_read_status() means that we may call into
      genphy_read_status() which in turn will use genphy_update_link() which
      can make changes to phydev->link outside of the state machine's state
      transitions. This is an invalid behavior that is now caught as of
      811a9191 ("phy state machine: failsafe leave invalid RUNNING state")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1105a2d3
    • David S. Miller's avatar
      Merge tag 'mlx5-updates-2017-01-31' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux · 501ec187
      David S. Miller authored
      Saeed Mahameed says:
      
      ====================
      mlx5-updates-2017-01-31
      
      This series includes some updates to mlx5 core and ethernet driver.
      
      We got one patch from Or to fix some static checker warnings.
      
      2nd patche from Dan came to add the support for 128B cache line
      in the HCA, which will configures the hardware to use 128B alignment only
      on systems with 128B cache lines, otherwise it will be kept as the current
      default of 64B.
      
      From me three patches to support no inline copy on TX on ConnectX-5 and
      later HCAs.  Starting with two small infrastructure changes and
      refactoring patches followed by two patches to add the actual support for
      both xmit ndo and XDP xmit routines.
      Last patch is a simple fix to return a mistakenly removed pointer from the
      SQ structure, which was remove in previous submission of mlx5 4K UAR.
      
      Saeed.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      501ec187
    • Ivan Khoronzhuk's avatar
      net: ethernet: ti: cpsw: remove netif_trans_update · 219189e7
      Ivan Khoronzhuk authored
      No need to update jiffies in txq->trans_start twice, it's supposed to be
      done in netdev_start_xmit() and anyway is re-written. Also, no reason to
      update trans time in case of an error.
      Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      219189e7
    • David S. Miller's avatar
      Merge branch 'bnxt_en-Add-XDP-support' · 919ce2a4
      David S. Miller authored
      Michael Chan says:
      
      ====================
      bnxt_en: Add XDP support.
      
      The first 10 patches refactor the code (rx/tx code paths and ring logic)
      and add the basic infrastructure to support XDP.  The 11th patch adds
      basic ndo_xdp to support XDP_DROP and XDP_PASS only.  The 12th patch
      completes the series with XDP_TX.
      
      Thanks to Andy Gospodarek for testing and uncovering some bugs.
      
      v3: Removed Kconfig option.
          Pass modified offset and length to stack for XDP_PASS.
          Improved buffer recycling scheme for XDP_TX.
          Other minor fixes.
      
      v2: Addressed review comments from Alexei Starovoitov, Jakub Kicinski,
      and David Miller:
      	- Added missing dma syncs.
      	- Added XDP headroom support.
      	- Added tracing in exception path.
      	- Clarified a parameter change.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      919ce2a4
    • Michael Chan's avatar
      bnxt_en: Add support for XDP_TX action. · 38413406
      Michael Chan authored
      Add dedicated transmit function and transmit completion handler for
      XDP.  The XDP transmit logic and completion logic are different than
      regular TX ring.  The TX buffer is recycled back to the RX ring when
      it completes.
      
      v3: Improved the buffer recyling scheme for XDP_TX.
      
      v2: Add trace_xdp_exception().
          Add dma_sync.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Tested-by: default avatarAndy Gospodarek <gospo@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      38413406
    • Michael Chan's avatar
      bnxt_en: Add basic XDP support. · c6d30e83
      Michael Chan authored
      Add basic ndo_xdp support to setup and query program, configure the NIC
      to run in rx page mode, and support XDP_PASS, XDP_DROP, XDP_ABORTED
      actions only.
      
      v3: Pass modified offset and length to stack for XDP_PASS.
          Remove Kconfig option.
      
      v2: Added trace_xdp_exception()
          Added dma_syncs.
          Added XDP headroom support.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Tested-by: default avatarAndy Gospodarek <gospo@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c6d30e83
    • Michael Chan's avatar
      bnxt_en: Refactor tx completion path. · fa3e93e8
      Michael Chan authored
      XDP_TX requires a different function to handle completion.  Add a
      function pointer to handle tx completion logic.  Regular TX rings
      will be assigned the current bnxt_tx_int() for the ->tx_int()
      function pointer.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fa3e93e8
    • Michael Chan's avatar
      bnxt_en: Add a set of TX rings to support XDP. · 5f449249
      Michael Chan authored
      Add logic for an extra set of TX rings for XDP.  If enabled, this
      set of TX rings equals the number of RX rings and shares the same
      IRQ as the RX ring set.  A new field bp->tx_nr_rings_xdp is added
      to keep track of these TX XDP rings.  Adjust all other relevant functions
      to handle bp->tx_nr_rings_xdp.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5f449249
    • Michael Chan's avatar
      bnxt_en: Add tx ring mapping logic. · a960dec9
      Michael Chan authored
      To support XDP_TX, we need to add a set of dedicated TX rings, each
      associated with the NAPI of an RX ring.  To assign XDP rings and regular
      rings in a flexible way, we add a bp->tx_ring_map[] array to do the
      remapping.  The netdev txq index is stored in the new field txq_index
      so that we can retrieve the netdev txq when handling TX completions.
      In this patch, before we introduce XDP_TX, the mapping is 1:1.
      
      v2: Fixed a bug in bnxt_tx_int().
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a960dec9
    • Michael Chan's avatar
      bnxt_en: Centralize logic to reserve rings. · d1e7925e
      Michael Chan authored
      Currently, bnxt_setup_tc() and bnxt_set_channels() have similar and
      duplicated code to check and reserve rx and tx rings.  Add a new
      function bnxt_reserve_rings() to centralize the logic.  This will
      make it easier to add XDP_TX support which requires allocating a
      new set of TX rings.
      
      Also, the tx ring checking logic in bnxt_setup_msix() can be removed.
      The rings have been reserved before hand.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d1e7925e
    • Michael Chan's avatar
      bnxt_en: Use event bit map in RX path. · 4e5dbbda
      Michael Chan authored
      In the current code, we have separate rx_event and agg_event parameters
      to keep track of rx and aggregation events.  Combine these events into
      an u8 event mask with different bits defined for different events.  This
      way, it is easier to expand the logic to include XDP tx events.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4e5dbbda
    • Michael Chan's avatar
      bnxt_en: Add RX page mode support. · c61fb99c
      Michael Chan authored
      This mode is to support XDP.  In this mode, each rx ring is configured
      with page sized buffers for linear placement of each packet.  MTU will be
      restricted to what the page sized buffers can support.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c61fb99c
    • Michael Chan's avatar
      bnxt_en: Parameterize RX buffer offsets. · b3dba77c
      Michael Chan authored
      Convert the global constants BNXT_RX_OFFSET and BNXT_RX_DMA_OFFSET to
      device parameters.  This will make it easier to support XDP with
      headroom support which requires different RX buffer offsets.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b3dba77c
    • Michael Chan's avatar
      bnxt_en: Add bp->rx_dir field for rx buffer DMA direction. · 745fc05c
      Michael Chan authored
      When driver is running in XDP mode, rx buffers are DMA mapped as
      DMA_BIDIRECTIONAL.  Add a field so the code will map/unmap rx buffers
      according to this field.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      745fc05c
    • Michael Chan's avatar
      bnxt_en: Don't use DEFINE_DMA_UNMAP_ADDR to store DMA address in RX path. · 11cd119d
      Michael Chan authored
      To support XDP_TX, we need the RX buffer's DMA address to transmit the
      packet.  Convert the DMA address field to a permanent field in
      bnxt_sw_rx_bd.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      11cd119d
    • Michael Chan's avatar
      bnxt_en: Refactor rx SKB function. · 6bb19474
      Michael Chan authored
      Minor refactoring of bnxt_rx_skb() so that it can easily be replaced by
      a new function that handles packets in a single page.  Also, use a
      function pointer bp->rx_skb_func() to switch to a new function when
      we add the new mode in the next patch.
      
      Add a new field data_ptr that points to the packet data in the
      bnxt_sw_rx_bd structure.  The original data field is changed to void
      pointer so that it can either hold the kmalloc'ed data or a page
      pointer.
      
      The last parameter of bnxt_rx_skb() which was the length parameter is
      changed to include the payload offset of the packet in the upper 16 bit.
      The offset is needed to support the rx page mode and is not used in
      this existing function.
      
      v3: Added a new data_ptr parameter to bp->rx_skb_func().  The caller
      has the option to modify the starting address of the packet.  This
      will be needed when XDP with headroom support is added.
      
      v2: Changed the name of the last parameter to offset_and_len to make the
      code more clear.
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6bb19474
    • Timur Tabi's avatar
      net: qcom/emac: add ethool support for setting pause parameters · b44700e9
      Timur Tabi authored
      To support setting the pause parameters, the driver can no longer just
      mirror the PHY.  The set_pauseparam feature allows the driver to
      force the setting in the MAC, regardless of how the PHY is configured.
      This means that we now need to maintain an internal state for pause
      frame support, and so get_pauseparam also needs to be updated.
      
      If the interface is already running when the setting is changed, then
      the interface is reset.
      
      Note that if the MAC is configured to enable RX pause frame support
      (i.e. it transmits pause frames to throttle the other end), but the
      PHY is configured to block those frames, then the feature will not work.
      
      Also some buffer size initialization code into emac_init_adapter(),
      so that it lives with similar code, including the initializtion of
      pause frame support.
      Signed-off-by: default avatarTimur Tabi <timur@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b44700e9
    • David S. Miller's avatar
      Merge branch 'replace-dst_confirm' · 29ba6e74
      David S. Miller authored
      Julian Anastasov says:
      
      ====================
      net: dst_confirm replacement
      
      	This patchset addresses the problem of neighbour
      confirmation where received replies from one nexthop
      can cause confirmation of different nexthop when using
      the same dst. Thanks to YueHaibing <yuehaibing@huawei.com>
      for tracking the dst->pending_confirm problem.
      
      	Sockets can obtain cached output route. Such
      routes can be to known nexthop (rt_gateway=IP) or to be
      used simultaneously for different nexthop IPs by different
      subnet prefixes (nh->nh_scope = RT_SCOPE_HOST, rt_gateway=0).
      
      	At first look, there are more problems:
      
      - dst_confirm() sets flag on dst and not on dst->path,
      as result, indication is lost when XFRM is used
      
      - DNAT can change the nexthop, so the really used nexthop is
      not confirmed
      
      	So, the following solution is to avoid using
      dst->pending_confirm.
      
      	The current dst_confirm() usage is as follows:
      
      Protocols confirming dst on received packets:
      - TCP (1 dst per socket)
      - SCTP (1 dst per transport)
      - CXGB*
      
      Protocols supporting sendmsg with MSG_CONFIRM [ | MSG_PROBE ] to
      confirm neighbour:
      - UDP IPv4/IPv6
      - ICMPv4 PING
      - RAW IPv4/IPv6
      - L2TP/IPv6
      
      MSG_CONFIRM for other purposes (fix not needed):
      - CAN
      
      Sending without locking the socket:
      - UDP (when no cork)
      - RAW (when hdrincl=1)
      
      Redirects from old to new GW:
      - rt6_do_redirect
      
      	The patchset includes the following changes:
      
      1. sock: add sk_dst_pending_confirm flag
      
      - used only by TCP with patch 4 to remember the received
      indication in sk->sk_dst_pending_confirm
      
      2. net: add dst_pending_confirm flag to skbuff
      
      - skb->dst_pending_confirm will be used by all protocols
      in following patches, via skb_{set,get}_dst_pending_confirm
      
      3. sctp: add dst_pending_confirm flag
      
      - SCTP uses per-transport dsts and can not use
      sk->sk_dst_pending_confirm like TCP
      
      4. tcp: replace dst_confirm with sk_dst_confirm
      
      5. net: add confirm_neigh method to dst_ops
      
      - IPv4 and IPv6 provision for slow neigh lookups for MSG_PROBE users.
      I decided to use neigh lookup only for this case because on
      MSG_PROBE the skb may pass MTU checks but it does not reach
      the neigh confirmation code. This patch will be used from patch 6.
      
      - xfrm_confirm_neigh: we use the last tunnel address, if present.
      When there are only transports, the original dest address is used.
      
      6. net: use dst_confirm_neigh for UDP, RAW, ICMP, L2TP
      
      - dst_confirm conversion for UDP, RAW, ICMP and L2TP/IPv6
      
      - these protocols use MSG_CONFIRM propagated by ip*_append_data
      to skb->dst_pending_confirm. sk->sk_dst_pending_confirm is not
      used because some sending paths do not lock the socket. For
      MSG_PROBE we use the slow lookup (dst_confirm_neigh).
      
      - there are also 2 cases that need the slow lookup:
      __ip6_rt_update_pmtu and rt6_do_redirect. I hope
      &ipv6_hdr(skb)->saddr is the correct nexthop address to use here.
      
      7. net: pending_confirm is not used anymore
      
      - I failed to understand the CXGB* code, I see dst_confirm()
      calls but I'm not sure dst_neigh_output() was called. For now
      I just removed the dst->pending_confirm flag and left all
      dst_confirm() calls there. Any better idea?
      
      - Now may be old function neigh_output() should be restored
      instead of dst_neigh_output?
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      29ba6e74
    • Julian Anastasov's avatar
      net: pending_confirm is not used anymore · 51ce8bd4
      Julian Anastasov authored
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      As last step, we can remove the pending_confirm flag.
      Reported-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Fixes: 5110effe ("net: Do delayed neigh confirmation.")
      Fixes: f2bb4bed ("ipv4: Cache output routes in fib_info nexthops.")
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      51ce8bd4
    • Julian Anastasov's avatar
      net: use dst_confirm_neigh for UDP, RAW, ICMP, L2TP · 0dec879f
      Julian Anastasov authored
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      
      The datagram protocols can use MSG_CONFIRM to confirm the
      neighbour. When used with MSG_PROBE we do not reach the
      code where neighbour is confirmed, so we have to do the
      same slow lookup by using the dst_confirm_neigh() helper.
      When MSG_PROBE is not used, ip_append_data/ip6_append_data
      will set the skb flag dst_pending_confirm.
      Reported-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Fixes: 5110effe ("net: Do delayed neigh confirmation.")
      Fixes: f2bb4bed ("ipv4: Cache output routes in fib_info nexthops.")
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0dec879f
    • Julian Anastasov's avatar
      net: add confirm_neigh method to dst_ops · 63fca65d
      Julian Anastasov authored
      Add confirm_neigh method to dst_ops and use it from IPv4 and IPv6
      to lookup and confirm the neighbour. Its usage via the new helper
      dst_confirm_neigh() should be restricted to MSG_PROBE users for
      performance reasons.
      
      For XFRM prefer the last tunnel address, if present. With help
      from Steffen Klassert.
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      63fca65d
    • Julian Anastasov's avatar
      tcp: replace dst_confirm with sk_dst_confirm · c3a2e837
      Julian Anastasov authored
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      Use the new sk_dst_confirm() helper to propagate the
      indication from received packets to sock_confirm_neigh().
      Reported-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Fixes: 5110effe ("net: Do delayed neigh confirmation.")
      Fixes: f2bb4bed ("ipv4: Cache output routes in fib_info nexthops.")
      Tested-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c3a2e837
    • Julian Anastasov's avatar
      sctp: add dst_pending_confirm flag · c86a773c
      Julian Anastasov authored
      Add new transport flag to allow sockets to confirm neighbour.
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      The flag is propagated from transport to every packet.
      It is reset when cached dst is reset.
      Reported-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Fixes: 5110effe ("net: Do delayed neigh confirmation.")
      Fixes: f2bb4bed ("ipv4: Cache output routes in fib_info nexthops.")
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c86a773c
    • Julian Anastasov's avatar
      net: add dst_pending_confirm flag to skbuff · 4ff06203
      Julian Anastasov authored
      Add new skbuff flag to allow protocols to confirm neighbour.
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      
      Add sock_confirm_neigh() helper to confirm the neighbour and
      use it for IPv4, IPv6 and VRF before dst_neigh_output.
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ff06203
    • Julian Anastasov's avatar
      sock: add sk_dst_pending_confirm flag · 9b8805a3
      Julian Anastasov authored
      Add new sock flag to allow sockets to confirm neighbour.
      When same struct dst_entry can be used for many different
      neighbours we can not use it for pending confirmations.
      As not all call paths lock the socket use full word for
      the flag.
      
      Add sk_dst_confirm as replacement for dst_confirm when
      called for received packets.
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9b8805a3
    • Florian Fainelli's avatar
      net: phy: bcm7xxx: Add BCM74371 PHY ID · b08d46b0
      Florian Fainelli authored
      Add the BCM74371 PHY ID to the list of supported chips. This is a 28nm
      technology Gigabit PHY SoC.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b08d46b0
    • Arnd Bergmann's avatar
      mlxsw: add psample dependency for spectrum · 8d1fb01d
      Arnd Bergmann authored
      When PSAMPLE is a loadable module, spectrum must not be built-in:
      
      drivers/net/built-in.o: In function `mlxsw_sp_rx_listener_sample_func':
      spectrum.c:(.text+0xe357e): undefined reference to `psample_sample_packet'
      
      This adds a Kconfig dependency to enforce usable configurations.
      
      Fixes: 98d0f7b9 ("mlxsw: spectrum: Add packet sample offloading support")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarYotam Gigi <yotamg@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8d1fb01d
    • Wei Yongjun's avatar
      ipv6: sr: fix non static symbol warnings · bb4005ba
      Wei Yongjun authored
      Fixes the following sparse warnings:
      
      net/ipv6/seg6_iptunnel.c:58:5: warning:
       symbol 'nla_put_srh' was not declared. Should it be static?
      net/ipv6/seg6_iptunnel.c:238:5: warning:
       symbol 'seg6_input' was not declared. Should it be static?
      net/ipv6/seg6_iptunnel.c:254:5: warning:
       symbol 'seg6_output' was not declared. Should it be static?
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bb4005ba
    • Wei Yongjun's avatar
      net/sched: act_mirred: remove duplicated include from act_mirred.c · 89d82452
      Wei Yongjun authored
      Remove duplicated include.
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      89d82452
    • Wei Yongjun's avatar
      net: wan: slic_ds26522: Remove .owner field for driver · fee40221
      Wei Yongjun authored
      Remove .owner field if calls are used which set it automatically.
      
      Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fee40221
    • Wei Yongjun's avatar
      net: wan: slic_ds26522: Use module_spi_driver to simplify the code · c3afa995
      Wei Yongjun authored
      module_spi_driver() makes the code simpler by eliminating
      boilerplate code.
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c3afa995
    • David S. Miller's avatar
      Merge branch 'dsa2-pdata' · 521613c5
      David S. Miller authored
      Florian Fainelli says:
      
      ====================
      net: dsa: Support for pdata in dsa2
      
      This is not exactly new, and was sent before, although back then, I did not
      have an user of the pre-declared MDIO board information, but now we do. Note
      that I have additional changes queued up to have b53 register platform data for
      MIPS bcm47xx and bcm63xx.
      
      Yes I know that we should have the Orion platforms eventually be converted to
      Device Tree, but until that happens, I don't want any remaining users of the
      old "dsa" platform device (hence the previous DTS submissions for ARM/mvebu)
      and, there will be platforms out there that most likely won't never see DT
      coming their way (BCM47xx is almost 100% sure, BCM63xx maybe not in a distant
      future).
      
      We would probably want the whole series to be merged via David Miller's tree
      to simplify things.
      
      Thanks!
      
      Changes in v5:
      
      - dropped changes to drivers/base/ because after more than a month, we cannot
        get any answer from Greg KH
      
      Changes in v4:
      
      - Changed device_find_class() to device_find_in_class_name()
      - Added kerneldoc above device_find_in_class_name() to explain what it does
        and the calling convention regarding device reference counts
      - Changed dev_to_net_device to device_to_net_device() added comments
        about what it does and the caller conventions regarding reference counts
      
      Changes in v3:
      
      - Tested EPROBE_DEFER from a mockup MDIO/DSA switch driver and everything
        is fine, once the driver finally probes we have access to platform data
        as expected
      
      - added comment above dsa_port_is_valid() that port->name is mandatory
        for platform data cases
      
      - added an extra check in dsa_parse_member() for a NULL pdata pointer
      
      - fixed a bunch of checkpatch errors and warnings
      
      Changes in v2:
      
      - Rebased against latest net-next/master
      
      - Moved dev_find_class() to device_find_class() into drivers/base/core.c
      
      - Moved dev_to_net_device into net/core/dev.c
      
      - Utilize dsa_chip_data directly instead of dsa_platform_data
      
      - Augmented dsa_chip_data to be multi-CPU port ready
      
      Changes from last submission (few months back):
      
      - rebased against latest net-next
      
      - do not introduce dsa2_platform_data which was overkill and was meant to
        allow us to do exaclty the same things with platform data and Device Tree
        we use the existing dsa_platform_data instead
      
      - properly register MDIO devices when the MDIO bus is registered and associate
        platform_data with them
      
      - add a change to the Orion platform code to demonstrate how this can be used
      
      Thank you
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      521613c5
    • Florian Fainelli's avatar
      ARM: orion: Register DSA switch as a MDIO device · 575e93f7
      Florian Fainelli authored
      Utilize the ability to pass board specific MDIO bus information towards a
      particular MDIO device thus allowing us to provide the per-port switch layout
      to the Marvell 88E6XXX switch driver.
      
      Since we would end-up with conflicting registration paths, do not register the
      "dsa" platform device anymore.
      
      Note that the MDIO devices registered by code in net/dsa/dsa2.c does not
      parse a dsa_platform_data, but directly take a dsa_chip_data (specific
      to a single switch chip), so we update the different call sites to pass
      this structure down to orion_ge00_switch_init().
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      575e93f7
    • Florian Fainelli's avatar
      net: phy: Allow pre-declaration of MDIO devices · 648ea013
      Florian Fainelli authored
      Allow board support code to collect pre-declarations for MDIO devices by
      registering them with mdiobus_register_board_info(). SPI and I2C buses
      have a similar feature, we were missing this for MDIO devices, but this
      is particularly useful for e.g: MDIO-connected switches which need to
      provide their port layout (often board-specific) to a MDIO Ethernet
      switch driver.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      648ea013
    • Florian Fainelli's avatar
      net: dsa: Add support for platform data · 71e0bbde
      Florian Fainelli authored
      Allow drivers to use the new DSA API with platform data. Most of the
      code in net/dsa/dsa2.c does not rely so much on device_nodes and can get
      the same information from platform_data instead.
      
      We purposely do not support distributed configurations with platform
      data, so drivers should be providing a pointer to a 'struct
      dsa_chip_data' structure if they wish to communicate per-port layout.
      
      Multiple CPUs port could potentially be supported and dsa_chip_data is
      extended to receive up to one reference to an upstream network device
      per port described by a dsa_chip_data structure.
      
      dsa_dev_to_net_device() increments the network device's reference count,
      so we intentionally call dev_put() to be consistent with the DT-enabled
      path, until we have a generic notifier based solution.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      71e0bbde
    • Florian Fainelli's avatar
      net: dsa: Rename and export dev_to_net_device() · 14b89f36
      Florian Fainelli authored
      In preparation for using this function in net/dsa/dsa2.c, rename the function
      to make its scope DSA specific, and export it.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      14b89f36
    • Andrew Lunn's avatar
      net: dsa: mv88e6xxx: Refactor remaining port setup · a23b2961
      Andrew Lunn authored
      Move the remaining port configuration code which varies per device
      into port.c, using ops were necessary. This makes
      mv88e6xxx_6185_family() and mv88e6xxx_6095_family() unused, so remove
      them.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a23b2961
    • Andrew Lunn's avatar
      net: dsa: mv88e6xxx: Implement Clause 45 access to SMI devices · cf3e80df
      Andrew Lunn authored
      The mv88e6390 MDIO bus controllers can support for clause 45 accesses.
      The internal SERDES interfaces need this, and it is likely external
      10GHz PHYs will be clause 45.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cf3e80df
    • David S. Miller's avatar
      Merge branch 'mv88e6390-CMODE' · 8661a631
      David S. Miller authored
      Andrew Lunn says:
      
      ====================
      Set the CMODE for mv88e6390 ports
      
      The mv88e6390 ports 9 & 10 allow there CMODE to be set. CMODE is part
      of what linux defines as phy-mode. Add the needed phy-modes to linux,
      and add code which will act upon the phy-mode property to configure
      the switch port.
      
      These patches have been posted before as part of a bigger patchset
      which has now been broken up. I've added the received reviewed by
      tags, and added device tree documentation.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8661a631
    • Andrew Lunn's avatar
      net: dsa: mv88e6xxx: Set the CMODE for mv88e6390 ports 9 & 10 · f39908d3
      Andrew Lunn authored
      Unlike most ports, ports 9 and 10 of the 6390X family have configurable
      PHY modes. Set the mode as part of adjust_link().
      
      Ordering is important, because the SERDES interfaces connected to
      ports 9 and 10 can be split and assigned to other ports. The CMODE has
      to be correctly set before the SERDES interface on another port can be
      configured. Such configuration is likely to be performed in
      port_enable() and port_disabled(), called on slave_open() and
      slave_close().
      
      The simple case is port 9 and 10 are used for 'CPU' or 'DSA'. In this
      case, the CMODE is set via a phy-mode in dsa_cpu_dsa_setup(), which is
      called early in the switch setup.
      
      When ports 9 or 10 are used as user ports, and have a fixed-phy, when
      the fixed fixed-phy is attached, dsa_slave_adjust_link() is called,
      which results in the adjust_link function being called, setting the
      cmode. The port_enable() will for other ports will be called much
      later.
      
      When ports 9 or 10 are used as user ports and have a real phy attached
      which does not use all the available SERDES interface, e.g. a 1Gbps
      SGMII, there is currently no mechanism in place to set the CMODE of
      the port from software. It must be hoped the stripping resistors are
      correct.
      
      At the same time, add a function to get the cmode. This will be needed
      when configuring the SERDES interfaces.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f39908d3