1. 09 Feb, 2019 27 commits
    • Russell King's avatar
      net: marvell: mvpp2: fix stuck in-band SGMII negotiation · 316734fd
      Russell King authored
      It appears that the mvpp22 can get stuck with SGMII negotiation.  The
      symptoms are that in-band negotiation never completes and the partner
      (eg, PHY) never reports SGMII link up, or if it supports negotiation
      bypass, goes into negotiation bypass mode (which will happen when the
      PHY sees that the MAC is alive but gets no response.)
      
      Triggering the PHY end of the link to re-negotiate results in the
      bypass bit clearing on the PHY, and then re-setting - indicating that
      the problem is at the mvpp22 GMAC end.
      
      Asserting the GMAC reset and de-asserting it resolves the issue.
      Arrange to assert the GMAC reset at probe time, and deassert it only
      after we have configured the GMAC for the appropriate mode.  This
      resolves the issue.
      Tested-by: default avatarSven Auhagen <sven.auhagen@voleatech.de>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      316734fd
    • Russell King's avatar
      net: marvell: mvpp2: phylink compliance updates · 388ca27f
      Russell King authored
      Sven Auhagen reported issues with negotiation on a couple of his
      platforms using a mixture of SFP and PHYs in various different
      modes.  Debugging to root cause proved difficult, but essentially
      the problem comes down to the mvpp2 phylink implementation being
      slightly at odds with what is expected.
      
      phylink operates in three modes: phy, fixed-link, and in-band mode.
      
      In the first two modes, the expected behaviour from a MAC driver is
      that phylink resolves the operating mode and passes the mode to the
      MAC driver for it to program, including when the link should be
      brought up or taken down.  This is basically the same as the libphy
      approach.  This does not negate the requirement to advertise a correct
      control word for interface modes that have control words where that
      can be reasonably controlled.
      
      The second mode is in-band mode, where the MAC is expected to use the
      in-band control word to determine the operating mode.
      
      The mvneta driver implements the correct pattern required to support
      this: configure the port interface type separately from the in-band
      mode(s).  This is now specified in the phylink documentation patches.
      
      mvpp2 was programming in-band mode for SGMII and the 802.3z modes no
      what, and avoided forcing the link up in fixed/phy modes.  This caused
      a problem with some boards where the PHY is by default programmed to
      enter AN bypass mode, the PHY would report that the link was up, but
      the mvpp2 never completed the exchange of control word.
      
      Another issue that mvpp2 has is it sets SGMII AN format control word
      for both SGMII and 802.3z modes. The format of the control word is
      defined by MVPP2_GMAC_INBAND_AN_MASK, which should be set for SGMII
      and clear for 802.3z. Available Marvell documentation for earlier
      GMAC implementations does not make this clear, but this has been
      ascertained via extensive testing on earlier GMAC implementations,
      and then confirmed with a Macchiatobin Single Shot connected to a
      Clearfog: when MVPP2_GMAC_INBAND_AN_MASK is set, the clearfog does
      not receive the advertised pause mode settings.
      
      Lastly, there is no flow control in the in-band control word in Cisco
      SGMII, setting the flow control autonegotiation bit even with a PHY
      that has the Marvell extension to send this information does not result
      in the flow control being enabled at the MAC.  We need to do this
      manually using the information provided via phylink.
      
      Re-code mvpp2's mac_config() and mac_link_up() to follow this pattern.
      This allows Sven Auhagen's board and Macchiatobin to reliably bring
      the link up with the 88e1512 PHY with phylink operating in PHY mode
      with COMPHY built as a module but the rest of the networking built-in,
      and u-boot having brought up the interface.  in-band mode requires an
      additional patch to resolve another problem.
      Tested-by: default avatarSven Auhagen <sven.auhagen@voleatech.de>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      388ca27f
    • Nathan Chancellor's avatar
      ethtool: Remove unnecessary null check in ethtool_rx_flow_rule_create · 8b34ec65
      Nathan Chancellor authored
      net/core/ethtool.c:3023:19: warning: address of array
      'ext_m_spec->h_dest' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
                      if (ext_m_spec->h_dest) {
                      ~~  ~~~~~~~~~~~~^~~~~~
      
      h_dest is an array, it can't be null so remove this check.
      
      Fixes: eca4205f ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
      Link: https://github.com/ClangBuiltLinux/linux/issues/353Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8b34ec65
    • Gustavo A. R. Silva's avatar
      ixgbe: Use struct_size() helper · 439bb9ed
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      Notice that, in this case, variable size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      439bb9ed
    • Gustavo A. R. Silva's avatar
      igc: Use struct_size() helper · 196d7311
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      196d7311
    • Gustavo A. R. Silva's avatar
      igb: use struct_size() helper · a0feac18
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = alloc(size, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      size = struct_size(instance, entry, count);
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a0feac18
    • Heiner Kallweit's avatar
      net: phy: don't double-read link status register if link is up · c397ab21
      Heiner Kallweit authored
      The link status register latches link-down events. Therefore, if link
      is reported as being up, there's no need for a second read.
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c397ab21
    • Gustavo A. R. Silva's avatar
      fm10k: use struct_size() in kzalloc() · 9a00536c
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      Notice that, in this case, variable size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9a00536c
    • Gustavo A. R. Silva's avatar
      nfp: flower: cmsg: use struct_size() helper · af6f12f2
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(void *);
      instance = alloc(size, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = alloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      Notice that, in this case, variable size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      af6f12f2
    • Gustavo A. R. Silva's avatar
      mlxsw: spectrum_router: Use struct_size() in kzalloc() · 9e475293
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable alloc_size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9e475293
    • Gustavo A. R. Silva's avatar
      bnx2x: Use struct_size() in kzalloc() · 370600af
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = kzalloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable fsz is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      370600af
    • Gustavo A. R. Silva's avatar
      wimax/i2400m: use struct_size() helper · 13644be2
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(void *);
      instance = alloc(size, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      size = struct_size(instance, entry, count);
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      13644be2
    • Gustavo A. R. Silva's avatar
      wan: wanxl: use struct_size() in kzalloc() · a3deec5b
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = alloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = alloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable alloc_size is not necessary, hence
      it is removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a3deec5b
    • Gustavo A. R. Silva's avatar
      net: usb: cdc-phonet: use struct_size() in alloc_netdev() · fd6d1226
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = alloc(sizeof(struct foo) + count * sizeof(void *));
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = alloc(struct_size(instance, entry, count));
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fd6d1226
    • Gustavo A. R. Silva's avatar
      net: dsa: use struct_size() in devm_kzalloc() · 33b363e0
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = alloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = alloc(struct_size(instance, entry, count), GFP_KERNEL)
      
      Notice that, in this case, variable size is not necessary, hence it is
      removed.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      33b363e0
    • Gustavo A. R. Silva's avatar
      mpls_iptunnel: use struct_size() helper · b4ba9354
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      instance = alloc(sizeof(struct foo) + count * sizeof(struct boo));
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = alloc(struct_size(instance, entry, count));
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b4ba9354
    • Gustavo A. R. Silva's avatar
      net/sched: use struct_size() helper · 8fe5756c
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = alloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      size = struct_size(instance, entry, count);
      instance = alloc(size, GFP_KERNEL)
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8fe5756c
    • Gustavo A. R. Silva's avatar
      bridge: use struct_size() helper · 4154b567
      Gustavo A. R. Silva authored
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      size = sizeof(struct foo) + count * sizeof(struct boo);
      instance = alloc(size, GFP_KERNEL)
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      size = struct_size(instance, entry, count);
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4154b567
    • David S. Miller's avatar
      Merge branch 'qed-SmartAN-query-support' · 6f0282bf
      David S. Miller authored
      Sudarsana Reddy Kalluru says:
      
      ====================
      qed*: SmartAN query support
      
      SmartAN feature detects the peer/cable capabilities and establishes the
      link in the best possible configuration.
      The patch series adds support for querying the capability. Please consider
      applying it net-next.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f0282bf
    • Sudarsana Reddy Kalluru's avatar
      qede: Add ethtool interface for SmartAN query. · f15cff04
      Sudarsana Reddy Kalluru authored
      The patch adds driver support to query SmartAN capability via ethtool.
      Signed-off-by: default avatarSudarsana Reddy Kalluru <skalluru@marvell.com>
      Signed-off-by: default avatarAriel Elior <aelior@marvell.com>
      Signed-off-by: default avatarMichal Kalderon <mkalderon@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f15cff04
    • Sudarsana Reddy Kalluru's avatar
      qed: Add API for SmartAN query. · df9c716d
      Sudarsana Reddy Kalluru authored
      The patch adds driver interface to read the SmartAN capability from
      management firmware.
      Signed-off-by: default avatarSudarsana Reddy Kalluru <skalluru@marvell.com>
      Signed-off-by: default avatarAriel Elior <aelior@marvell.com>
      Signed-off-by: default avatarMichal Kalderon <mkalderon@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      df9c716d
    • David S. Miller's avatar
      Merge branch 'net-dsa-bcm_sf2-Add-support-for-CFP-statistics' · bc794e6e
      David S. Miller authored
      Florian Fainelli says:
      
      ====================
      net: dsa: bcm_sf2: Add support for CFP statistics
      
      The Broadcom SF2 switch has a Compact Field Processor (CFP) which not
      only can perform matching + action, but also counts the number of times
      a rule has been hit. This is invaluable while debugging when/if rules
      are not matched.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bc794e6e
    • Florian Fainelli's avatar
      net: dsa: bcm_sf2: Allow looping back CFP rules · db78ed27
      Florian Fainelli authored
      When the source and destination port of a CFP rule match, we must set
      the loopback bit enable to allow that, otherwise the frame is discarded.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      db78ed27
    • Florian Fainelli's avatar
      net: dsa: bcm_sf2: Add support for CFP statistics · f4ae9c08
      Florian Fainelli authored
      Return CFP policer statistics (Green, Yellow or Red) as part of the
      standard ethtool statistics. This helps debug when CFP rules may not be
      hit (0 counter).
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f4ae9c08
    • Florian Fainelli's avatar
      net: dsa: bcm_sf2: Prepare for adding CFP statistics · badd62c2
      Florian Fainelli authored
      In preparation for adding CFP statistics, we will need to overlay the
      standard B53 statistics, so create specific bcm_sf2_sw_* functions to
      call into their b53_common.c counterpart.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      badd62c2
    • Florian Fainelli's avatar
      net: dsa: bcm_sf2: Remove stats mutex · 1f03f260
      Florian Fainelli authored
      We no longer need a dedicated statistics mutex since we leverage
      b53_common for statistics now.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1f03f260
    • Heiner Kallweit's avatar
      net: phy: consider latched link-down status in polling mode · 93c09704
      Heiner Kallweit authored
      The link status value latches link-down events. To get the current
      status we read the register twice in genphy_update_link(). There's
      a potential risk that we miss a link-down event in polling mode.
      This may cause issues if the user e.g. connects his machine to a
      different network.
      
      On the other hand reading the latched value may cause issues in
      interrupt mode. Following scenario:
      
      - After boot link goes up
      - phy_start() is called triggering an aneg restart, hence link goes
        down and link-down info is latched.
      - After aneg has finished link goes up and triggers an interrupt.
        Interrupt handler reads link status, means it reads the latched
        "link is down" info. But there won't be another interrupt as long
        as link stays up, therefore phylib will never recognize that link
        is up.
      
      Deal with both scenarios by reading the register twice in interrupt
      mode only.
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      93c09704
  2. 08 Feb, 2019 13 commits