1. 19 4月, 2017 14 次提交
  2. 18 4月, 2017 1 次提交
    • J
      net: mvneta: fix failed to suspend if WOL is enabled · 82960fff
      Jisheng Zhang 提交于
      Recently, suspend/resume and WOL support are added into mvneta driver.
      If we enable WOL, then we get some error as below on Marvell BG4CT
      platforms during suspend:
      
      [  184.149723] dpm_run_callback(): mdio_bus_suspend+0x0/0x50 returns -16
      [  184.149727] PM: Device f7b62004.mdio-mi:00 failed to suspend: error -16
      
      -16 means -EBUSY, phy_suspend() will return -EBUSY if it finds the
      device has WOL enabled.
      
      We fix this issue by properly setting the netdev's power.can_wakeup
      and power.wakeup, i.e
      
      1. in mvneta_mdio_probe(), call device_set_wakeup_capable() to set
      power.can_wakeup if the phy support WOL.
      
      2. in mvneta_ethtool_set_wol(), call device_set_wakeup_enable() to
      set power.wakeup if WOL has been successfully enabled in phy.
      Signed-off-by: NJisheng Zhang <jszhang@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      82960fff
  3. 13 4月, 2017 4 次提交
  4. 30 3月, 2017 2 次提交
  5. 17 3月, 2017 1 次提交
  6. 10 3月, 2017 18 次提交
    • T
      net: mvpp2: finally add the PPv2.2 compatible string · fc5e1550
      Thomas Petazzoni 提交于
      Now that the mvpp2 driver has been modified to accommodate the support
      for PPv2.2, we can finally advertise this support by adding the
      appropriate compatible string.
      
      At the same time, we update the Kconfig description of the MVPP2 driver.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fc5e1550
    • T
      net: mvpp2: set dma mask and coherent dma mask on PPv2.2 · 2067e0a1
      Thomas Petazzoni 提交于
      On PPv2.2, the streaming mappings can be anywhere in the first 40 bits
      of the physical address space. However, for the coherent mappings, we
      still need them to be in the first 32 bits of the address space,
      because all BM pools share a single register to store the high 32 bits
      of the BM pool address, which means all BM pools must be allocated in
      the same 4GB memory area.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2067e0a1
    • T
      net: mvpp2: add support for an additional clock needed for PPv2.2 · fceb55d4
      Thomas Petazzoni 提交于
      The PPv2.2 variant of the network controller needs an additional
      clock, the "MG clock" in order for the IP block to operate
      properly. This commit adds support for this additional clock to the
      driver, reworking as needed the error handling path.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fceb55d4
    • T
      net: mvpp2: adapt rxq distribution to PPv2.2 · 59b9a31e
      Thomas Petazzoni 提交于
      In PPv2.1, we have a maximum of 8 RXQs per port, with a default of 4
      RXQs per port, and we were assigning RXQs 0->3 to the first port, 4->7
      to the second port, 8->11 to the third port, etc.
      
      In PPv2.2, we have a maximum of 32 RXQs per port, and we must allocate
      RXQs from the range of 32 RXQs available for each port. So port 0 must
      use RXQs in the range 0->31, port 1 in the range 32->63, etc.
      
      This commit adapts the mvpp2 to this difference between PPv2.1 and
      PPv2.2:
      
       - The constant definition MVPP2_MAX_RXQ is replaced by a new field
         'max_port_rxqs' in 'struct mvpp2', which stores the maximum number of
         RXQs per port. This field is initialized during ->probe() depending
         on the IP version.
      
       - MVPP2_RXQ_TOTAL_NUM is removed, and instead we calculate the total
         number of RXQs by multiplying the number of ports by the maximum of
         RXQs per port. This was anyway used in only one place.
      
       - In mvpp2_port_probe(), the calculation of port->first_rxq is adjusted
         to cope with the different allocation strategy between PPv2.1 and
         PPv2.2. Due to this change, the 'next_first_rxq' argument of this
         function is no longer needed and is removed.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59b9a31e
    • T
      net: mvpp2: rework RXQ interrupt group initialization for PPv2.2 · a73fef10
      Thomas Petazzoni 提交于
      This commit adjusts how the MVPP2_ISR_RXQ_GROUP_REG register is
      configured, since it changed between PPv2.1 and PPv2.2.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a73fef10
    • T
      net: mvpp2: add AXI bridge initialization for PPv2.2 · 6763ce31
      Thomas Petazzoni 提交于
      The PPv2.2 unit is connected to an AXI bus on Armada 7K/8K, so this
      commit adds the necessary initialization of the AXI bridge.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6763ce31
    • T
      net: mvpp2: handle misc PPv2.1/PPv2.2 differences · 26975821
      Thomas Petazzoni 提交于
      This commit handles a few miscellaneous differences between PPv2.1 and
      PPv2.2 in different areas, where code done for PPv2.1 doesn't apply for
      PPv2.2 or needs to be adjusted (getting the MAC address, disabling PHY
      polling, etc.).
      
      Thanks to Russell King for providing the initial implementation of
      mvpp22_port_mii_set().
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      26975821
    • T
      net: mvpp2: handle register mapping and access for PPv2.2 · a786841d
      Thomas Petazzoni 提交于
      This commit adjusts the mvpp2 driver register mapping and access logic
      to support PPv2.2, to handle a number of differences.
      
      Due to how the registers are laid out in memory, the Device Tree binding
      for the "reg" property is different:
      
       - On PPv2.1, we had a first area for the packet processor
         registers (common to all ports), and then one area per port.
      
       - On PPv2.2, we have a first area for the packet processor
         registers (common to all ports), and a second area for numerous other
         registers, including a large number of per-port registers
      
      In addition, on PPv2.2, the area for the common registers is split into
      so-called "address spaces" of 64 KB each. They allow to access per-CPU
      registers, where each CPU has its own copy of some registers. A few
      other registers, which have a single copy, also need to be accessed from
      those per-CPU windows if they are related to a per-CPU register. For
      example:
      
        - Writing to MVPP2_TXQ_NUM_REG selects a TX queue. This register is a
          per-CPU register, it must be accessed from the current CPU register
          window.
      
        - Then a write to MVPP2_TXQ_PENDING_REG, MVPP2_TXQ_DESC_ADDR_REG (and
          a few others) will affect the TX queue that was selected by the
          write to MVPP2_TXQ_NUM_REG. It must be accessed from the same CPU
          window as the write to the TXQ_NUM_REG.
      
      Therefore, the ->base member of 'struct mvpp2' is replaced with a
      ->cpu_base[] array, each entry pointing to a mapping of the per-CPU
      area. Since PPv2.1 doesn't have this concept of per-CPU windows, all
      entries in ->cpu_base[] point to the same io-remapped area.
      
      The existing mvpp2_read() and mvpp2_write() accessors use cpu_base[0],
      they are used for registers for which the CPU window doesn't matter.
      
      mvpp2_percpu_read() and mvpp2_percpu_write() are new accessors added to
      access the registers for which the CPU window does matter, which is why
      they take a "cpu" as argument.
      
      The driver is then changed to use mvpp2_percpu_read() and
      mvpp2_percpu_write() where it matters.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a786841d
    • T
      net: mvpp2: adjust mvpp2_{rxq, txq}_init for PPv2.2 · b02f31fb
      Thomas Petazzoni 提交于
      In PPv2.2, the MVPP2_RXQ_DESC_ADDR_REG and MVPP2_TXQ_DESC_ADDR_REG
      registers have a slightly different layout, because they need to contain
      a 64-bit address for the RX and TX descriptor arrays. This commit
      adjusts those functions accordingly.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b02f31fb
    • T
      net: mvpp2: adapt mvpp2_defaults_set() to PPv2.2 · 3d9017d9
      Thomas Petazzoni 提交于
      This commit modifies the mvpp2_defaults_set() function to not do the
      loopback and FIFO threshold initialization, which are not needed for
      PPv2.2.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3d9017d9
    • T
      net: mvpp2: adapt the mvpp2_rxq_*_pool_set functions to PPv2.2 · 5eac892a
      Thomas Petazzoni 提交于
      The MVPP2_RXQ_CONFIG_REG register has a slightly different layout
      between PPv2.1 and PPv2.2, so this commit adapts the functions modifying
      this register to accommodate for both the PPv2.1 and PPv2.2 cases.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5eac892a
    • T
      net: mvpp2: adjust the allocation/free of BM pools for PPv2.2 · d01524d8
      Thomas Petazzoni 提交于
      This commit adjusts the allocation and freeing of BM pools to support
      PPv2.2. This involves:
      
       - Checking that the number of buffer pointers is a multiple of 16, as
         required by the hardware.
      
       - Adjusting the size of the DMA coherent area allocated for buffer
         pointers. Indeed, PPv2.2 needs space for 2 pointers of 64-bits per
         buffer, as opposed to 2 pointers of 32-bits per buffer in
         PPv2.1. The size in bytes is now stored in a new field of the
         mvpp2_bm_pool structure.
      
       - On PPv2.2, getting the DMA address and cookie (used for the physical
         address) of each buffer requires reading the
         MVPP22_BM_ADDR_HIGH_ALLOC to get the high order bits of those
         addresses. A new utility function mvpp2_bm_bufs_get_addrs() is
         introduced to handle this.
      
       - On PPv2.2, releasing a buffer requires writing the high order 32 bits
         of the DMA address and cookie to MVPP22_BM_PHY_VIRT_HIGH_RLS_REG.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d01524d8
    • T
      net: mvpp2: introduce PPv2.2 HW descriptors and adapt accessors · e7c5359f
      Thomas Petazzoni 提交于
      This commit adds the definition of the PPv2.2 HW descriptors, adjusts
      the mvpp2_tx_desc and mvpp2_rx_desc structures accordingly, and adapts
      the accessors to work on both PPv2.1 and PPv2.2.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e7c5359f
    • T
      net: mvpp2: introduce an intermediate union for the TX/RX descriptors · 054f6372
      Thomas Petazzoni 提交于
      Since the format of the HW descriptors is different between PPv2.1 and
      PPv2.2, this commit introduces an intermediate union, with for now
      only the PPv2.1 descriptors. The bulk of the driver code only
      manipulates opaque mvpp2_tx_desc and mvpp2_rx_desc pointers, and the
      descriptors can only be accessed and modified through the accessor
      functions. A follow-up commit will add the descriptor definitions for
      PPv2.2.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      054f6372
    • T
      net: mvpp2: add hw_version field in "struct mvpp2" · faca9247
      Thomas Petazzoni 提交于
      In preparation to the introduction for the support of PPv2.2 in the
      mvpp2 driver, this commit adds a hw_version field to the struct
      mvpp2, and uses the .data field of the DT match table to fill it in.
      
      Having the MVPP21 and MVPP22 definitions available will allow to start
      adding the necessary conditional code to support PPv2.2.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      faca9247
    • T
      net: mvpp2: add and use accessors for TX/RX descriptors · ac3dd277
      Thomas Petazzoni 提交于
      The PPv2.2 IP has a different TX and RX descriptor layout compared to
      PPv2.1. In order to prepare for the introduction of PPv2.2 support in
      mvpp2, this commit adds accessors for the different fields of the TX
      and RX descriptors, and changes the code to use them.
      
      For now, the mvpp2_port argument passed to the accessors is not used,
      but it will be used in follow-up to update the descriptor according to
      the version of the IP being used.
      
      Apart from the mechanical changes to use the newly introduced
      accessors, a few other changes, needed to use the accessors, are made:
      
       - The mvpp2_txq_inc_put() function now takes a mvpp2_port as first
         argument, as it is needed to use the accessors.
      
       - Similarly, the mvpp2_bm_cookie_build() gains a mvpp2_port first
         argument, for the same reason.
      
       - In mvpp2_rx_error(), instead of accessing the RX descriptor in each
         case of the switch, we introduce a local variable to store the
         packet size.
      
       - In mvpp2_tx_frag_process() and mvpp2_tx() instead of accessing the
         packet size from the TX descriptor, we use the actual value
         available in the function, which is used to set the TX descriptor
         packet size a few lines before.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ac3dd277
    • T
      net: mvpp2: store physical address of buffer in rx_desc->buf_cookie · 4e4a105f
      Thomas Petazzoni 提交于
      The RX descriptors of the PPv2 hardware allow to store several
      information, amongst which:
      
       - the DMA address of the buffer in which the data has been received
       - a "cookie" field, left to the use of the driver, and not used by the
         hardware
      
      In the current implementation, the "cookie" field is used to store the
      virtual address of the buffer, so that in the receive completion path,
      we can easily get the virtual address of the buffer that corresponds to
      a completed RX descriptors.
      
      On PPv2.1, used on 32-bit platforms, those two fields are 32-bit wide,
      which is enough to store a DMA address in the first field, and a virtual
      address in the second field.
      
      On PPv2.2, used on 64-bit platforms, these two fields have been extended
      to 40 bits. While 40 bits is enough to store a DMA address (as long as
      the DMA mask is 40 bits or lower), it is not enough to store a virtual
      address. Therefore, the "cookie" field can no longer be used to store
      the virtual address of the buffer.
      
      However, as Russell King pointed out, the RX buffers are always
      allocated in the kernel linear mapping, and therefore using
      phys_to_virt() on the physical address of the RX buffer is possible and
      correct.
      
      Therefore, this commit changes the driver to use the "cookie" field to
      store the physical address instead of the virtual
      address. phys_to_virt() is used in the receive completion path to
      retrieve the virtual address from the physical address.
      
      It is obviously important to realize that the DMA address and physical
      address are two different things, which is why we store both in the RX
      descriptors. While those addresses may be identical in some situations,
      it remains two distinct concepts, and both addresses should be handled
      separately.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4e4a105f
    • T
      net: mvpp2: remove mvpp2_txq_pend_desc_num_get() function · 4d6c2a67
      Thomas Petazzoni 提交于
      The mvpp2_txq_pend_desc_num_get() function only selects a TX queue, and
      reads the number of pending descriptors. It is used in only one place,
      in mvpp2_txq_clean(), where the TX queue has already been selected by a
      write to MVPP2_TXQ_NUM_REG.
      
      Therefore, this function is useless, and the caller can simply read the
      value of the MVPP2_TXQ_PENDING_REG register instead.
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4d6c2a67