mbox series

[net-next,00/19] net: ethernet: ti: clean up and optimizations

Message ID 1556024950-20752-1-git-send-email-grygorii.strashko@ti.com
Headers show
Series net: ethernet: ti: clean up and optimizations | expand

Message

Grygorii Strashko April 23, 2019, 1:08 p.m. UTC
Hi All,

This is a preparation series for introducing new switchbase TI CPSW driver which
was originally introduced [1][2] by Ilias Apalodimas <ilias.apalodimas@linaro.org> 
and also discussed in private mails and at Netdev x13 confernce.

Following discussions and suggestions (mostly by Andrew and Ivan) we going
to introduce the new driver which is operating in dual-emac mode
by default, thus working as 2 individual network interfaces.
When both interfaces joined the bridge - CPSW driver will enter a switch
mode and discard dual_mac configuration. The CPSW will be switched back
to dual_mac mode if any port leaves the bridge. All configuration is going to be
implemented via switchdev API.

Hence overall change is already very big I'm sending prerequisite patches which
are mostly minor fixes/clean ups and code refactoring to separate common parts
to be reused by both drivers.
Probably the most serious change from functional point of view is Patch 11.

These patches were NFS boot tetested on TI AM335x/AM437x/AM5xx boards.

These patches can be found at:
 git@git.ti.com:~gragst/ti-linux-kernel/gragsts-ti-linux-kernel.git
 branch: lkml-5.1-cpsw-clean-up

Functional new cpsw_switch driver (still fighting with few issues) can be found:
 git@git.ti.com:~gragst/ti-linux-kernel/gragsts-ti-linux-kernel.git
 branch: lkml-5.1-switch-tbd

[1] https://patchwork.ozlabs.org/cover/929367/
[2] https://patches.linaro.org/cover/136709/

Grygorii Strashko (19):
  net: ethernet: ti: convert to SPDX license identifiers
  net: ethernet: ti: cpsw: drop TI_DAVINCI_CPDMA config option
  net: ethernet: ti: cpsw: drop CONFIG_TI_CPSW_ALE config option
  net: ethernet: ti: cpsw: update cpsw_split_res() to accept cpsw_common
  net: ethernet: ti: cpsw: use local var dev in probe
  net: ethernet: ti: cpsw: drop pinctrl_pm_select_default_state call
  net: ethernet: ti: cpsw: use devm_alloc_etherdev_mqs()
  net: ethernet: ti: cpsw: drop cpsw_tx_packet_submit()
  net: ethernet: ti: ale: fix mcast super setting
  net: ethernet: ti: ale: use define for host port in cpsw_ale_set_allmulti()
  net: ethernet: ti: cpsw: fix allmulti cfg in dual_mac mode
  net: ethernet: ti: ale: do not auto delete mcast super entries
  net: ethernet: ti: davinci_mdio: use devm_ioremap()
  net: ethernet: ti: cpsw: refactor probe to group common hw initialization
  net: ethernet: ti: cpsw: move cpsw definitions in priv header
  net: ethernet: ti: cpsw: move common hw init code in separate func
  net: ethernet: ti: cpsw: introduce mac sl module api
  net: ethernet: ti: cpsw: switch to use mac sl api
  net: ethernet: ti: cpsw: move ethtool func in separate file

 drivers/net/ethernet/ti/Kconfig          |   19 -
 drivers/net/ethernet/ti/Makefile         |    9 +-
 drivers/net/ethernet/ti/cpmac.c          |   14 +-
 drivers/net/ethernet/ti/cpsw-common.c    |   12 +-
 drivers/net/ethernet/ti/cpsw-phy-sel.c   |    9 +-
 drivers/net/ethernet/ti/cpsw.c           | 1544 +++-------------------
 drivers/net/ethernet/ti/cpsw.h           |    9 +-
 drivers/net/ethernet/ti/cpsw_ale.c       |   44 +-
 drivers/net/ethernet/ti/cpsw_ale.h       |   11 +-
 drivers/net/ethernet/ti/cpsw_ethtool.c   |  719 ++++++++++
 drivers/net/ethernet/ti/cpsw_priv.c      |  131 ++
 drivers/net/ethernet/ti/cpsw_priv.h      |  441 ++++++
 drivers/net/ethernet/ti/cpsw_sl.c        |  327 +++++
 drivers/net/ethernet/ti/cpsw_sl.h        |   73 +
 drivers/net/ethernet/ti/cpts.c           |   14 +-
 drivers/net/ethernet/ti/cpts.h           |   14 +-
 drivers/net/ethernet/ti/davinci_cpdma.c  |   35 +-
 drivers/net/ethernet/ti/davinci_cpdma.h  |    9 +-
 drivers/net/ethernet/ti/davinci_emac.c   |   16 +-
 drivers/net/ethernet/ti/davinci_mdio.c   |   19 +-
 drivers/net/ethernet/ti/netcp.h          |   10 +-
 drivers/net/ethernet/ti/netcp_core.c     |   10 +-
 drivers/net/ethernet/ti/netcp_ethss.c    |   10 +-
 drivers/net/ethernet/ti/netcp_sgmii.c    |    9 +-
 drivers/net/ethernet/ti/netcp_xgbepcsr.c |    9 +-
 25 files changed, 1878 insertions(+), 1639 deletions(-)
 create mode 100644 drivers/net/ethernet/ti/cpsw_ethtool.c
 create mode 100644 drivers/net/ethernet/ti/cpsw_priv.c
 create mode 100644 drivers/net/ethernet/ti/cpsw_priv.h
 create mode 100644 drivers/net/ethernet/ti/cpsw_sl.c
 create mode 100644 drivers/net/ethernet/ti/cpsw_sl.h

-- 
2.17.1

Comments

Andrew Lunn April 23, 2019, 6:37 p.m. UTC | #1
On Tue, Apr 23, 2019 at 04:08:54PM +0300, Grygorii Strashko wrote:
> index 1142fcfce566..3ef5257c9bc7 100644

> --- a/drivers/net/ethernet/ti/cpsw_ale.c

> +++ b/drivers/net/ethernet/ti/cpsw_ale.c

>  

>  MODULE_LICENSE("GPL v2");

>  MODULE_DESCRIPTION("TI CPSW ALE driver");


Hi Grygorii

If this is no longer a module, the MODULE_* macros don't make much
sense.

	Andrew
Andrew Lunn April 23, 2019, 6:40 p.m. UTC | #2
>On Tue, Apr 23, 2019 at 04:08:56PM +0300, Grygorii Strashko wrote:

> Use local variable struct device *dev in probe to simplify code.

> 

> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

> ---

>  drivers/net/ethernet/ti/cpsw.c | 65 +++++++++++++++++-----------------

>  1 file changed, 33 insertions(+), 32 deletions(-)

> 

> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c

> index 13a339c64892..0b8cc4e6d9cd 100644

> --- a/drivers/net/ethernet/ti/cpsw.c

> +++ b/drivers/net/ethernet/ti/cpsw.c

> @@ -3458,6 +3458,7 @@ static const struct soc_device_attribute cpsw_soc_devices[] = {

>  

>  static int cpsw_probe(struct platform_device *pdev)

>  {

> +	struct device *dev = &pdev->dev;

>  	struct clk			*clk;

>  	struct cpsw_platform_data	*data;

>  	struct net_device		*ndev;


It seems odd not to keep with the column layout?
Plus it would make it reverse Christmas tree.

     Andrew
Andrew Lunn April 23, 2019, 6:40 p.m. UTC | #3
On Tue, Apr 23, 2019 at 04:08:57PM +0300, Grygorii Strashko wrote:
> Drop pinctrl_pm_select_default_state call from probe as default

> pinctrl state is set by DD core.

> 

> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
Andrew Lunn April 23, 2019, 6:42 p.m. UTC | #4
On Tue, Apr 23, 2019 at 04:08:59PM +0300, Grygorii Strashko wrote:
> Drop unnecessary wrapper function cpsw_tx_packet_submit() which is used

> only in one place.

> 

> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
Andrew Lunn April 23, 2019, 6:43 p.m. UTC | #5
On Tue, Apr 23, 2019 at 04:09:01PM +0300, Grygorii Strashko wrote:
> Use ALE_PORT_HOST define for host port in cpsw_ale_set_allmulti() instead

> of constants.

> 

> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
Andrew Lunn April 23, 2019, 6:53 p.m. UTC | #6
On Tue, Apr 23, 2019 at 04:09:07PM +0300, Grygorii Strashko wrote:
> +	ret = cpsw_init_common(cpsw, ss_regs, ale_ageout,

> +			       (u32 __force)ss_res->start + CPSW2_BD_OFFSET,

> +			       descs_pool_size);


Hi Grygorii

Could you put it onto your TODO list to remove this nasty casting.

Thanks

      Andrew
Grygorii Strashko April 24, 2019, 9:20 a.m. UTC | #7
On 23.04.19 21:40, Andrew Lunn wrote:
>> On Tue, Apr 23, 2019 at 04:08:56PM +0300, Grygorii Strashko wrote:

>> Use local variable struct device *dev in probe to simplify code.

>>

>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

>> ---

>>  drivers/net/ethernet/ti/cpsw.c | 65 +++++++++++++++++-----------------

>>  1 file changed, 33 insertions(+), 32 deletions(-)

>>

>> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c

>> index 13a339c64892..0b8cc4e6d9cd 100644

>> --- a/drivers/net/ethernet/ti/cpsw.c

>> +++ b/drivers/net/ethernet/ti/cpsw.c

>> @@ -3458,6 +3458,7 @@ static const struct soc_device_attribute cpsw_soc_devices[] = {

>>  

>>  static int cpsw_probe(struct platform_device *pdev)

>>  {

>> +	struct device *dev = &pdev->dev;

>>  	struct clk			*clk;

>>  	struct cpsw_platform_data	*data;

>>  	struct net_device		*ndev;

> 

> It seems odd not to keep with the column layout?

> Plus it would make it reverse Christmas tree.


It's has never been optimized for Christmas tree and
I'll keep cur layout for now.

-- 
Best regards,
grygorii
Grygorii Strashko April 24, 2019, 9:31 a.m. UTC | #8
On 24.04.19 03:27, Jakub Kicinski wrote:
> On Tue, 23 Apr 2019 16:08:53 +0300, Grygorii Strashko wrote:

>> Both drivers CPSW and EMAC can't work without CPDMA, hence simplify build

>> of those drivers by always linking davinci_cpdma and drop TI_DAVINCI_CPDMA

>> config option.

>> Note. the davinci_emac driver module was changed to "ti_davinci_emac" to

>> make build work.

>>

>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

> 

> Last time I tried including the same object file in two different

> modules it backfired pretty badly.  Would you mind sparing some 

> details as to why you need to do this?


I've tried it as modules and inbuid and see no issues.
Issue with build happens if EXPORT_SYMBOL_GPL() not removed.

It's not expected and not supported to load more then one TI Net
driver at same hw, so modules also are just be loaded fine.

Why? It's to get rid of CONFIG options which were historically added,
but are not required now (and even can't be disabled of if disabled will
cause build failures) - result simplified build/Kconfig and code.


-- 
Best regards,
grygorii
Grygorii Strashko April 24, 2019, 9:31 a.m. UTC | #9
Andrew,

On 23.04.19 16:58, Andrew Lunn wrote:
> On Tue, Apr 23, 2019 at 04:08:52PM +0300, Grygorii Strashko wrote:

>> +// SPDX-License-Identifier: GPL-2.0

>>  /*

>>   * Copyright (C) 2006, 2007 Eugene Konev

>>   *

>> - * This program is free software; you can redistribute it and/or modify

>> - * it under the terms of the GNU General Public License as published by

>> - * the Free Software Foundation; either version 2 of the License, or

>> - * (at your option) any later version.

> 

> Your SPDX says version 2. The text says version 2 or later. You need

> to add a + .

Thanks for your comments. I'll update and resend.

-- 
Best regards,
grygorii
Grygorii Strashko April 24, 2019, 2:55 p.m. UTC | #10
On 24.04.19 15:22, Ivan Khoronzhuk wrote:
> On Tue, Apr 23, 2019 at 04:09:02PM +0300, Grygorii Strashko wrote:

>> Now CPSW ALE will set/clean Host port bit in Unregistered Multicast Flood

>> Mask (UNREG_MCAST_FLOOD_MASK) for every VLAN without checking if this port

>> belongs to VLAN or not when ALLMULTI mode flag is set for nedev. This is

>> working in non dual_mac mode, but in dual_mac - it causes

>> enabling/disabling ALLMULTI flag for both ports.

>>

>> Hence fix it by adding additional parameter to cpsw_ale_set_allmulti() to

>> specify ALE port number for which ALLMULTI has to be enabled and check if

>> port belongs to VLAN before modifying UNREG_MCAST_FLOOD_MASK.

>>

>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

>> ---

>> drivers/net/ethernet/ti/cpsw.c     | 12 +++++++++---

>> drivers/net/ethernet/ti/cpsw_ale.c | 12 ++++++++++--

>> drivers/net/ethernet/ti/cpsw_ale.h |  2 +-

>> 3 files changed, 20 insertions(+), 6 deletions(-)

>>

> [...]

>> +        vlan_members =

>> +            cpsw_ale_get_vlan_member_list(ale_entry,

>> +                              ale->vlan_field_bits);

> Seems like declaration for cpsw_ale_get_vlan_member_list() is not

> part of the patchset

> 

> 


It's define :)
DEFINE_ALE_FIELD1(vlan_member_list,	0)


-- 
Best regards,
grygorii
Grygorii Strashko April 25, 2019, 2:14 p.m. UTC | #11
On 25.04.19 16:38, Murali Karicheri wrote:
> On 04/23/2019 09:09 AM, Grygorii Strashko wrote:

>> move common hw init code in separate function as preparation for adding new

>> switchdev driver.

> All of the changes indicates a better name for the file is cpsw_common.c; commit log,

 new function cpsw_init_common() etc. Any specific reason to use cpsw_priv.[ch]?

I've been thinking about this, but cpsw_coomon.c is used by davinici_emac also.
More over, I have a hope that it'd be possible to get rid of cpsw_common.c at all
by switching to nvmem.

Also, I'd be very appreciated if you'd be able to cut your replies.
It's a little bit hard to find your comments

> 

>>

>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

>> ---

>>   drivers/net/ethernet/ti/Makefile    |   2 +-

>>   drivers/net/ethernet/ti/cpsw.c      | 106 ++---------------------

>>   drivers/net/ethernet/ti/cpsw_priv.c | 128 ++++++++++++++++++++++++++++

>>   drivers/net/ethernet/ti/cpsw_priv.h |   3 +

>>   4 files changed, 137 insertions(+), 102 deletions(-)

>>   create mode 100644 drivers/net/ethernet/ti/cpsw_priv.c

>>

>> diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile

>> index 2f159a71f88e..de1561596646 100644

...

-- 
Best regards,
grygorii