1. 09 11月, 2018 1 次提交
    • I
      net: ethernet: ti: cpsw: fix vlan mcast · 15180eca
      Ivan Khoronzhuk 提交于
      At this moment, mcast addresses are added for real device only
      (reserved vlans for dual-emac mode), even if a mcast address was added
      for some vlan only, thus ALE doesn't have corresponding vlan mcast
      entries after vlan socket joined multicast group. So ALE drops vlan
      frames with mcast addresses intended for vlans and potentially can
      receive mcast frames for base ndev. That's not correct. So, fix it by
      creating only vlan/mcast entries as requested. Patch doesn't use any
      additional lists and is based on device mc address list and cpsw ALE
      table entries.
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      15180eca
  2. 23 10月, 2018 1 次提交
  3. 22 10月, 2018 1 次提交
  4. 16 10月, 2018 2 次提交
    • I
      net: ethernet: ti: cpsw: use for mcast entries only host port · 5b3a5a14
      Ivan Khoronzhuk 提交于
      In dual-emac mode the cpsw driver sends directed packets, that means
      that packets go to the directed port, but an ALE lookup is performed
      to determine untagged egress only. It means that on tx side no need
      to add port bit for ALE mcast entry mask, and basically ALE entry
      for port identification is needed only on rx side.
      
      So, add only host port in dual_emac mode as used directed
      transmission, and no need in one more port. For single port boards
      and switch mode all ports used, as usual, so no changes for them.
      Also it simplifies farther changes.
      
      In other words, mcast entries for dual-emac should behave exactly
      like unicast. It also can help avoid leaking packets between ports
      with same vlan on h/w level if ports could became members of same vid.
      
      So now, for instance, if mcast address 33:33:00:00:00:01 is added then
      entries in ALE table:
      
      vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x1
      vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x1
      
      Instead of:
      vid = 1, addr = 33:33:00:00:00:01, port_mask = 0x3
      vid = 2, addr = 33:33:00:00:00:01, port_mask = 0x5
      
      With the same considerations, set only host port for unregistered
      mcast for dual-emac mode in case of IFF_ALLMULTI is set, exactly like
      it's done in cpsw_ale_set_allmulti().
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5b3a5a14
    • I
      net: ethernet: ti: cpsw: fix lost of mcast packets while rx_mode update · 5da19489
      Ivan Khoronzhuk 提交于
      Whenever kernel or user decides to call rx mode update, it clears
      every multicast entry from forwarding table and in some time adds
      it again. This time can be enough to drop incoming multicast packets.
      
      That's why clear only staled multicast entries and update or add new
      one afterwards.
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5da19489
  5. 20 9月, 2018 1 次提交
  6. 12 8月, 2018 2 次提交
  7. 02 8月, 2018 1 次提交
  8. 30 7月, 2018 1 次提交
  9. 24 7月, 2018 4 次提交
    • I
      net: ethernet: ti: cpsw: restore shaper configuration while down/up · 4b4255ed
      Ivan Khoronzhuk 提交于
      Need to restore shapers configuration after interface was down/up.
      This is needed as appropriate configuration is still replicated in
      kernel settings. This only shapers context restore, so vlan
      configuration should be restored by user if needed, especially for
      devices with one port where vlan frames are sent via ALE.
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4b4255ed
    • I
      net: ethernet: ti: cpsw: add CBS Qdisc offload · 57d90148
      Ivan Khoronzhuk 提交于
      The cpsw has up to 4 FIFOs per port and upper 3 FIFOs can feed rate
      limited queue with shaping. In order to set and enable shaping for
      those 3 FIFOs queues the network device with CBS qdisc attached is
      needed. The CBS configuration is added for dual-emac/single port mode
      only, but potentially can be used in switch mode also, based on
      switchdev for instance.
      
      Despite the FIFO shapers can work w/o cpdma level shapers the base
      usage must be in combine with cpdma level shapers as described in TRM,
      that are set as maximum rates for interface queues with sysfs.
      
      One of the possible configuration with txq shapers and CBS shapers:
      
                            Configured with echo RATE >
                        /sys/class/net/eth0/queues/tx-0/tx_maxrate
                   /---------------------------------------------------
                  /
                 /            cpdma level shapers
              +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+
              | c7 | | c6 | | c5 | | c4 | | c3 | | c2 | | c1 | | c0 |
              \    / \    / \    / \    / \    / \    / \    / \    /
               \  /   \  /   \  /   \  /   \  /   \  /   \  /   \  /
                \/     \/     \/     \/     \/     \/     \/     \/
      +---------|------|------|------|-------------------------------------+
      |    +----+      |      |  +---+                                     |
      |    |      +----+      |  |                                         |
      |    v      v           v  v                                         |
      | +----+ +----+ +----+ +----+ p        p+----+ +----+ +----+ +----+  |
      | |    | |    | |    | |    | o        o|    | |    | |    | |    |  |
      | | f3 | | f2 | | f1 | | f0 | r  CPSW  r| f3 | | f2 | | f1 | | f0 |  |
      | |    | |    | |    | |    | t        t|    | |    | |    | |    |  |
      | \    / \    / \    / \    / 0        1\    / \    / \    / \    /  |
      |  \  X   \  /   \  /   \  /             \  /   \  /   \  /   \  /   |
      |   \/ \   \/     \/     \/               \/     \/     \/     \/    |
      +-------\------------------------------------------------------------+
               \
                \ FIFO shaper, set with CBS offload added in this patch,
                 \ FIFO0 cannot be rate limited
                  ------------------------------------------------------
      
      CBS shaper configuration is supposed to be used with root MQPRIO Qdisc
      offload allowing to add sk_prio->tc->txq maps that direct traffic to
      appropriate tx queue and maps L2 priority to FIFO shaper.
      
      The CBS shaper is intended to be used for AVB where L2 priority
      (pcp field) is used to differentiate class of traffic. So additionally
      vlan needs to be created with appropriate egress sk_prio->l2 prio map.
      
      If CBS has several tx queues assigned to it, the sum of their
      bandwidth has not overlap bandwidth set for CBS. It's recomended the
      CBS bandwidth to be a little bit more.
      
      The CBS shaper is configured with CBS qdisc offload interface using tc
      tool from iproute2 packet.
      
      For instance:
      
      $ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
      
      $ tc -g class show dev eth0
      +---(100:ffe2) mqprio
      |    +---(100:3) mqprio
      |    +---(100:4) mqprio
      |    
      +---(100:ffe1) mqprio
      |    +---(100:2) mqprio
      |    
      +---(100:ffe0) mqprio
           +---(100:1) mqprio
      
      $ tc qdisc add dev eth0 parent 100:1 cbs locredit -1440 \
      hicredit 60 sendslope -960000 idleslope 40000 offload 1
      
      $ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
      hicredit 62 sendslope -980000 idleslope 20000 offload 1
      
      The above code set CBS shapers for tc0 and tc1, for that txq0 and
      txq1 is used. Pay attention, the real set bandwidth can differ a bit
      due to discreteness of configuration parameters.
      
      Here parameters like locredit, hicredit and sendslope are ignored
      internally and are supposed to be set with assumption that maximum
      frame size for frame - 1500.
      
      It's supposed that interface speed is not changed while reconnection,
      not always is true, so inform user in case speed of interface was
      changed, as it can impact on dependent shapers configuration.
      
      For more examples see Documentation.
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      57d90148
    • I
      net: ethernet: ti: cpsw: add MQPRIO Qdisc offload · 7929a668
      Ivan Khoronzhuk 提交于
      That's possible to offload vlan to tc priority mapping with
      assumption sk_prio == L2 prio.
      
      Example:
      $ ethtool -L eth0 rx 1 tx 4
      
      $ qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
      map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
      
      $ tc -g class show dev eth0
      +---(100:ffe2) mqprio
      |    +---(100:3) mqprio
      |    +---(100:4) mqprio
      |    
      +---(100:ffe1) mqprio
      |    +---(100:2) mqprio
      |    
      +---(100:ffe0) mqprio
           +---(100:1) mqprio
      
      Here, 100:1 is txq0, 100:2 is txq1, 100:3 is txq2, 100:4 is txq3
      txq0 belongs to tc0, txq1 to tc1, txq2 and txq3 to tc2
      The offload part only maps L2 prio to classes of traffic, but not
      to transmit queues, so to direct traffic to traffic class vlan has
      to be created with appropriate egress map.
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7929a668
    • I
      net: ethernet: ti: cpsw: use cpdma channels in backward order for txq · 79b3325d
      Ivan Khoronzhuk 提交于
      The cpdma channel highest priority is from hi to lo number.
      The driver has limited number of descriptors that are shared between
      number of cpdma channels. Number of queues can be tuned with ethtool,
      that allows to not spend descriptors on not needed cpdma channels.
      In AVB usually only 2 tx queues can be enough with rate limitation.
      The rate limitation can be used only for hi priority queues. Thus, to
      use only 2 queues the 8 has to be created. It's wasteful.
      
      So, in order to allow using only needed number of rate limited
      tx queues, save resources, and be able to set rate limitation for
      them, let assign tx cpdma channels in backward order to queues.
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      79b3325d
  10. 07 7月, 2018 2 次提交
  11. 23 6月, 2018 1 次提交
  12. 13 6月, 2018 1 次提交
    • K
      treewide: devm_kzalloc() -> devm_kcalloc() · a86854d0
      Kees Cook 提交于
      The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
      This patch replaces cases of:
      
              devm_kzalloc(handle, a * b, gfp)
      
      with:
              devm_kcalloc(handle, a * b, gfp)
      
      as well as handling cases of:
      
              devm_kzalloc(handle, a * b * c, gfp)
      
      with:
      
              devm_kzalloc(handle, array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              devm_kcalloc(handle, array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              devm_kzalloc(handle, 4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      Some manual whitespace fixes were needed in this patch, as Coccinelle
      really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      expression HANDLE;
      type TYPE;
      expression THING, E;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression HANDLE;
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      expression HANDLE;
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      expression HANDLE;
      identifier SIZE, COUNT;
      @@
      
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression HANDLE;
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression HANDLE;
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      expression HANDLE;
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        devm_kzalloc(HANDLE,
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression HANDLE;
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        devm_kzalloc(HANDLE,
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression HANDLE;
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
      |
        devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
      |
        devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
      |
        devm_kzalloc(HANDLE, C1 * C2, ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - devm_kzalloc
      + devm_kcalloc
        (HANDLE,
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      a86854d0
  13. 01 6月, 2018 1 次提交
    • A
      net: ti: cpsw: include gpio/consumer.h · e2b3e493
      Arnd Bergmann 提交于
      On platforms that don't always enable CONFIG_GPIOLIB, we run into
      a build failure:
      
      drivers/net/ethernet/ti/cpsw.c: In function 'cpsw_probe':
      drivers/net/ethernet/ti/cpsw.c:3006:9: error: implicit declaration of function 'devm_gpiod_get_array_optional' [-Werror=implicit-function-declaration]
        mode = devm_gpiod_get_array_optional(&pdev->dev, "mode", GPIOD_OUT_LOW);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/net/ethernet/ti/cpsw.c:3006:59: error: 'GPIOD_OUT_LOW' undeclared (first use in this function); did you mean 'GPIOF_INIT_LOW'?
        mode = devm_gpiod_get_array_optional(&pdev->dev, "mode", GPIOD_OUT_LOW);
      
      Since we cannot rely on this to be visible from gpio.h, we have to include
      gpio/consumer.h directly.
      
      Fixes: 2652113f ("net: ethernet: ti: Allow most drivers with COMPILE_TEST")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e2b3e493
  14. 22 5月, 2018 1 次提交
  15. 18 5月, 2018 1 次提交
  16. 02 5月, 2018 1 次提交
    • G
      net: ethernet: ti: cpsw: fix packet leaking in dual_mac mode · 5e5add17
      Grygorii Strashko 提交于
      In dual_mac mode packets arrived on one port should not be forwarded by
      switch hw to another port. Only Linux Host can forward packets between
      ports. The below test case (reported in [1]) shows that packet arrived on
      one port can be leaked to anoter (reproducible with dual port evms):
       - connect port 1 (eth0) to linux Host 0 and run tcpdump or Wireshark
       - connect port 2 (eth1) to linux Host 1 with vlan 1 configured
       - ping <IPx> from Host 1 through vlan 1 interface.
      ARP packets will be seen on Host 0.
      
      Issue happens because dual_mac mode is implemnted using two vlans: 1 (Port
      1+Port 0) and 2 (Port 2+Port 0), so there are vlan records created for for
      each vlan. By default, the ALE will find valid vlan record in its table
      when vlan 1 tagged packet arrived on Port 2 and so forwards packet to all
      ports which are vlan 1 members (like Port.
      
      To avoid such behaviorr the ALE VLAN ID Ingress Check need to be enabled
      for each external CPSW port (ALE_PORTCTLn.VID_INGRESS_CHECK) so ALE will
      drop ingress packets if Rx port is not VLAN member.
      Signed-off-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5e5add17
  17. 23 4月, 2018 1 次提交
  18. 06 4月, 2018 1 次提交
    • R
      headers: untangle kmemleak.h from mm.h · 514c6032
      Randy Dunlap 提交于
      Currently <linux/slab.h> #includes <linux/kmemleak.h> for no obvious
      reason.  It looks like it's only a convenience, so remove kmemleak.h
      from slab.h and add <linux/kmemleak.h> to any users of kmemleak_* that
      don't already #include it.  Also remove <linux/kmemleak.h> from source
      files that do not use it.
      
      This is tested on i386 allmodconfig and x86_64 allmodconfig.  It would
      be good to run it through the 0day bot for other $ARCHes.  I have
      neither the horsepower nor the storage space for the other $ARCHes.
      
      Update: This patch has been extensively build-tested by both the 0day
      bot & kisskb/ozlabs build farms.  Both of them reported 2 build failures
      for which patches are included here (in v2).
      
      [ slab.h is the second most used header file after module.h; kernel.h is
        right there with slab.h. There could be some minor error in the
        counting due to some #includes having comments after them and I didn't
        combine all of those. ]
      
      [akpm@linux-foundation.org: security/keys/big_key.c needs vmalloc.h, per sfr]
      Link: http://lkml.kernel.org/r/e4309f98-3749-93e1-4bb7-d9501a39d015@infradead.org
      Link: http://kisskb.ellerman.id.au/kisskb/head/13396/Signed-off-by: NRandy Dunlap <rdunlap@infradead.org>
      Reviewed-by: NIngo Molnar <mingo@kernel.org>
      Reported-by: Michael Ellerman <mpe@ellerman.id.au>	[2 build failures]
      Reported-by: Fengguang Wu <fengguang.wu@intel.com>	[2 build failures]
      Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Wei Yongjun <weiyongjun1@huawei.com>
      Cc: Luis R. Rodriguez <mcgrof@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      514c6032
  19. 18 3月, 2018 2 次提交
    • G
      net: ethernet: ti: cpsw: enable vlan rx vlan offload · a3a41d2f
      Grygorii Strashko 提交于
      In VLAN_AWARE mode CPSW can insert VLAN header encapsulation word on Host
      port 0 egress (RX) before the packet data if RX_VLAN_ENCAP bit is set in
      CPSW_CONTROL register. VLAN header encapsulation word has following format:
      
       HDR_PKT_Priority bits 29-31 - Header Packet VLAN prio (Highest prio: 7)
       HDR_PKT_CFI 	  bits 28 - Header Packet VLAN CFI bit.
       HDR_PKT_Vid 	  bits 27-16 - Header Packet VLAN ID
       PKT_Type         bits 8-9 - Packet Type. Indicates whether the packet is
                       	VLAN-tagged, priority-tagged, or non-tagged.
      	00: VLAN-tagged packet
      	01: Reserved
      	10: Priority-tagged packet
      	11: Non-tagged packet
      
      This feature can be used to implement TX VLAN offload in case of
      VLAN-tagged packets and to insert VLAN tag in case Non-tagged packet was
      received on port with PVID set. As per documentation, CPSW never modifies
      packet data on Host egress (RX) and as result, without this feature
      enabled, Host port will not be able to receive properly packets which
      entered switch non-tagged through external Port with PVID set (when
      non-tagged packet forwarded from external Port with PVID set to another
      external Port - packet will be VLAN tagged properly).
      
      Implementation details:
      - on RX driver will check CPDMA status bit RX_VLAN_ENCAP BIT(19) in CPPI
      descriptor to identify when VLAN header encapsulation word is present.
      - PKT_Type = 0x01 or 0x02 then ignore VLAN header encapsulation word and
      pass packet as is;
      - if HDR_PKT_Vid = 0 then ignore VLAN header encapsulation word and pass
      packet as is;
      - In dual mac mode traffic is separated between ports using default port
      vlans, which are not be visible to Host and so should not be reported.
      Hence, check for default port vlans in dual mac mode and ignore VLAN header
      encapsulation word;
      - otherwise fill SKB with VLAN info using __vlan_hwaccel_put_tag();
      - PKT_Type = 0x00 (VLAN-tagged) then strip out VLAN header from SKB.
      Signed-off-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a3a41d2f
    • S
      net: ethernet: ti: cpsw: add check for in-band mode setting with RGMII PHY interface · f9db5069
      SZ Lin (林上智) 提交于
      According to AM335x TRM[1] 14.3.6.2, AM437x TRM[2] 15.3.6.2 and
      DRA7 TRM[3] 24.11.4.8.7.3.3, in-band mode in EXT_EN(bit18) register is only
      available when PHY is configured in RGMII mode with 10Mbps speed. It will
      cause some networking issues without RGMII mode, such as carrier sense
      errors and low throughput. TI also mentioned this issue in their forum[4].
      
      This patch adds the check mechanism for PHY interface with RGMII interface
      type, the in-band mode can only be set in RGMII mode with 10Mbps speed.
      
      References:
      [1]: https://www.ti.com/lit/ug/spruh73p/spruh73p.pdf
      [2]: http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf
      [3]: http://www.ti.com/lit/ug/spruic2b/spruic2b.pdf
      [4]: https://e2e.ti.com/support/arm/sitara_arm/f/791/p/640765/2392155Suggested-by: NHolsety Chen (陳憲輝) <Holsety.Chen@moxa.com>
      Signed-off-by: NSZ Lin (林上智) <sz.lin@moxa.com>
      Signed-off-by: NSchuyler Patton <spatton@ti.com>
      Reviewed-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f9db5069
  20. 08 2月, 2018 1 次提交
    • G
      net: ethernet: ti: cpsw: fix net watchdog timeout · 62f94c21
      Grygorii Strashko 提交于
      It was discovered that simple program which indefinitely sends 200b UDP
      packets and runs on TI AM574x SoC (SMP) under RT Kernel triggers network
      watchdog timeout in TI CPSW driver (<6 hours run). The network watchdog
      timeout is triggered due to race between cpsw_ndo_start_xmit() and
      cpsw_tx_handler() [NAPI]
      
      cpsw_ndo_start_xmit()
      	if (unlikely(!cpdma_check_free_tx_desc(txch))) {
      		txq = netdev_get_tx_queue(ndev, q_idx);
      		netif_tx_stop_queue(txq);
      
      ^^ as per [1] barier has to be used after set_bit() otherwise new value
      might not be visible to other cpus
      	}
      
      cpsw_tx_handler()
      	if (unlikely(netif_tx_queue_stopped(txq)))
      		netif_tx_wake_queue(txq);
      
      and when it happens ndev TX queue became disabled forever while driver's HW
      TX queue is empty.
      
      Fix this, by adding smp_mb__after_atomic() after netif_tx_stop_queue()
      calls and double check for free TX descriptors after stopping ndev TX queue
      - if there are free TX descriptors wake up ndev TX queue.
      
      [1] https://www.kernel.org/doc/html/latest/core-api/atomic_ops.htmlSigned-off-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Reviewed-by: NIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      62f94c21
  21. 14 12月, 2017 1 次提交
  22. 02 12月, 2017 6 次提交
  23. 16 11月, 2017 1 次提交
    • G
      net: ethernet: ti: cpsw: fix min eth packet size · 9421c901
      Grygorii Strashko 提交于
      Now CPSW driver configures min eth packet size to 60 octets (ETH_ZLEN)
      which works in most of cases, but when port VLAN is configured on some
      switch port, it also can be configured to force all egress packets to be
      VLAN untagged. And in this case, CPSW driver will pad small packets to 60
      octets, but final packet size on port egress can became less than 60 octets
      due to VLAN tag removal and packet will be dropped.
      
      Hence, fix it by accounting VLAN header in CPSW min eth packet size. While
      here, use proper defines for CPSW_MAX_PACKET_SIZE also, instead of open
      coding.
      Signed-off-by: NGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9421c901
  24. 14 8月, 2017 1 次提交
  25. 25 7月, 2017 1 次提交
  26. 21 7月, 2017 1 次提交
  27. 30 6月, 2017 2 次提交