net: phy: marvell10g updates
Subsystems (5)
Marek Behún
maintainerv3 cover net: phy: marvell10g updates
Here are some updates for marvell10g PHY driver.
I am still working on some more changes for this driver, but I would like to have at least something reviewed / applied.
Changes since v2:
- code refactored to use an additional structure mv3310_chip describing mv3310 specific properties / operations for PHYs supported by this driver
- added separate phy_driver structures for 88X3340 and 88E2111
- removed 88E2180 specific code (dual-port and quad-port SXGMII modes are ignored for now)
Changes since v1:
- added various MACTYPEs support also for 88E21XX
- differentiate between specific models with same PHY_ID
- better check for compatible interface
- print exact model
Marek Behún (18):
net: phy: marvell10g: rename register
net: phy: marvell10g: fix typo
net: phy: marvell10g: allow 5gbase-r and usxgmii
net: phy: marvell10g: indicate 88X33x0 only port control registers
net: phy: marvell10g: add all MACTYPE definitions for 88X33x0
net: phy: marvell10g: add MACTYPE definitions for 88E21xx
net: phy: marvell10g: support all rate matching modes
include: add library helpers for variadic macro expansion
include: bitmap: add macro for bitmap initialization
net: phy: marvell10g: check for correct supported interface mode
net: phy: marvell10g: store temperature read method in chip strucutre
net: phy: marvell10g: support other MACTYPEs
net: phy: marvell10g: add separate structure for 88X3340
net: phy: marvell10g: fix driver name for mv88e2110
net: phy: add constants for 2.5G and 5G speed in PCS speed register
net: phy: marvell10g: differentiate 88E2110 vs 88E2111
net: phy: marvell10g: change module description
MAINTAINERS: add myself as maintainer of marvell10g driver
MAINTAINERS | 1 + drivers/net/phy/marvell10g.c | 369 +++++++++++++++++++++++++++------ include/linux/bitmap.h | 24 +++ include/linux/marvell_phy.h | 6 +- include/linux/variadic-macro.h | 221 ++++++++++++++++++++ include/uapi/linux/mdio.h | 2 + 6 files changed, 562 insertions(+), 61 deletions(-) create mode 100644 include/linux/variadic-macro.h
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 1/18 net: phy: marvell10g: rename register
The MV_V2_PORT_MAC_TYPE_* is part of the CTRL register. Rename to MV_V2_PORT_CTRL_MACTYPE_*.
--- drivers/net/phy/marvell10g.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/phy/marvell10g.c +4 -4
@@ -80,8 +80,8 @@ enum {MV_V2_PORT_CTRL =0xf001 ,MV_V2_PORT_CTRL_SWRST =BIT (15 ),MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), -MV_V2_PORT_MAC_TYPE_MASK =0x7 , -MV_V2_PORT_MAC_TYPE_RATE_MATCH =0x6 , +MV_V2_PORT_CTRL_MACTYPE_MASK =0x7 , +MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH =0x6 ,/* Temperature control/read registers (88X3310 only) */ MV_V2_TEMP_CTRL =0xf08a , MV_V2_TEMP_CTRL_MASK = 0xc000,
@@ -477,8 +477,8 @@ static int mv3310_config_init(struct phy_device *phydev) val =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL );if (val <0 )return val; - priv->rate_match = ((val &MV_V2_PORT_MAC_TYPE_MASK ) == -MV_V2_PORT_MAC_TYPE_RATE_MATCH ); + priv->rate_match = ((val &MV_V2_PORT_CTRL_MACTYPE_MASK ) == +MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH );/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 2/18 net: phy: marvell10g: fix typo
In reply to Marek BehúnThis space should be a tab instead.
--- drivers/net/phy/marvell10g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell10g.c +1 -1
@@ -79,7 +79,7 @@ enum {/* Vendor2 MMD registers */ MV_V2_PORT_CTRL =0xf001 ,MV_V2_PORT_CTRL_SWRST =BIT (15 ), -MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), +MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ),MV_V2_PORT_CTRL_MACTYPE_MASK =0x7 , MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH = 0x6,/* Temperature control/read registers (88X3310 only) */
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 3/18 net: phy: marvell10g: allow 5gbase-r and usxgmii
In reply to Marek BehúnThese modes are also supported by these PHYs.
--- drivers/net/phy/marvell10g.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/phy/marvell10g.c +7 -1
@@ -462,9 +462,11 @@ static int mv3310_config_init(struct phy_device *phydev)/* Check that the PHY interface type is compatible */ if (phydev->interface !=PHY_INTERFACE_MODE_SGMII && phydev->interface !=PHY_INTERFACE_MODE_2500BASEX && + phydev->interface !=PHY_INTERFACE_MODE_5GBASER && phydev->interface !=PHY_INTERFACE_MODE_XAUI && phydev->interface !=PHY_INTERFACE_MODE_RXAUI && - phydev->interface !=PHY_INTERFACE_MODE_10GBASER ) + phydev->interface !=PHY_INTERFACE_MODE_10GBASER && + phydev->interface !=PHY_INTERFACE_MODE_USXGMII )return -ENODEV ; phydev->mdix_ctrl =ETH_TP_MDI_AUTO ;
@@ -599,6 +601,7 @@ static void mv3310_update_interface(struct phy_device *phydev)if ((phydev->interface ==PHY_INTERFACE_MODE_SGMII || phydev->interface ==PHY_INTERFACE_MODE_2500BASEX || + phydev->interface ==PHY_INTERFACE_MODE_5GBASER || phydev->interface ==PHY_INTERFACE_MODE_10GBASER ) && phydev->link) {/* The PHY automatically switches its serdes interface (and
@@ -611,6 +614,9 @@ static void mv3310_update_interface(struct phy_device *phydev)case SPEED_10000 : phydev->interface =PHY_INTERFACE_MODE_10GBASER ;break ; +case SPEED_5000 : + phydev->interface =PHY_INTERFACE_MODE_5GBASER ; +break ;case SPEED_2500 : phydev->interface =PHY_INTERFACE_MODE_2500BASEX ;break ;
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 4/18 net: phy: marvell10g: indicate 88X33x0 only port control registers
In reply to Marek BehúnRename port control registers to indicate that they are valid only for 88X33x0, not for 88E21x0.
--- drivers/net/phy/marvell10g.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/phy/marvell10g.c +7 -7
@@ -78,10 +78,10 @@ enum {/* Vendor2 MMD registers */ MV_V2_PORT_CTRL =0xf001 , -MV_V2_PORT_CTRL_SWRST =BIT (15 ), -MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), -MV_V2_PORT_CTRL_MACTYPE_MASK =0x7 , -MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH =0x6 , +MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), +MV_V2_33X0_PORT_CTRL_SWRST =BIT (15 ), +MV_V2_33X0_PORT_CTRL_MACTYPE_MASK =0x7 , +MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH =0x6 ,/* Temperature control/read registers (88X3310 only) */ MV_V2_TEMP_CTRL =0xf08a , MV_V2_TEMP_CTRL_MASK = 0xc000,
@@ -268,7 +268,7 @@ static int mv3310_power_up(struct phy_device *phydev)return ret;return phy_set_bits_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL , -MV_V2_PORT_CTRL_SWRST ); +MV_V2_33X0_PORT_CTRL_SWRST ); }static int mv3310_reset (struct phy_device *phydev,u32 unit)
@@ -479,8 +479,8 @@ static int mv3310_config_init(struct phy_device *phydev) val =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL );if (val <0 )return val; - priv->rate_match = ((val &MV_V2_PORT_CTRL_MACTYPE_MASK ) == -MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH ); + priv->rate_match = ((val &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ) == +MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH );/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 5/18 net: phy: marvell10g: add all MACTYPE definitions for 88X33x0
In reply to Marek BehúnAdd all MACTYPE definitions for 88X3310, 88X3310P, 88X3340 and 88X3340P.
In order to have consistent naming, renameMV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH toMV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH.
--- drivers/net/phy/marvell10g.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/phy/marvell10g.c +13 -5
@@ -78,10 +78,18 @@ enum {/* Vendor2 MMD registers */ MV_V2_PORT_CTRL =0xf001 , -MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), -MV_V2_33X0_PORT_CTRL_SWRST =BIT (15 ), -MV_V2_33X0_PORT_CTRL_MACTYPE_MASK =0x7 , -MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH =0x6 , +MV_V2_PORT_CTRL_PWRDOWN =BIT (11 ), +MV_V2_33X0_PORT_CTRL_SWRST =BIT (15 ), +MV_V2_33X0_PORT_CTRL_MACTYPE_MASK =0x7 , +MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI =0x0 , +MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH =0x1 , +MV_V2_3340_PORT_CTRL_MACTYPE_RXAUI_NO_SGMII_AN =0x1 , +MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH =0x2 , +MV_V2_3310_PORT_CTRL_MACTYPE_XAUI =0x3 , +MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER =0x4 , +MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN =0x5 , +MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH =0x6 , +MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII =0x7 ,/* Temperature control/read registers (88X3310 only) */ MV_V2_TEMP_CTRL =0xf08a , MV_V2_TEMP_CTRL_MASK = 0xc000,
@@ -480,7 +488,7 @@ static int mv3310_config_init(struct phy_device *phydev)if (val <0 )return val; priv->rate_match = ((val &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ) == -MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH ); +MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH );/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 6/18 net: phy: marvell10g: add MACTYPE definitions for 88E21xx
In reply to Marek BehúnAdd all MACTYPE definitions for 88E2110, 88E2180, 88E2111 and 88E2181.
--- drivers/net/phy/marvell10g.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/phy/marvell10g.c +9 -0
@@ -35,6 +35,15 @@enum {MV_PMA_FW_VER0 =0xc011 ,MV_PMA_FW_VER1 =0xc012 , +MV_PMA_21X0_PORT_CTRL =0xc04a , +MV_PMA_21X0_PORT_CTRL_SWRST =BIT (15 ), +MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK =0x7 , +MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII =0x0 , +MV_PMA_2180_PORT_CTRL_MACTYPE_DXGMII =0x1 , +MV_PMA_2180_PORT_CTRL_MACTYPE_QXGMII =0x2 , +MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER =0x4 , +MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN =0x5 , +MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH =0x6 ,MV_PMA_BOOT =0xc050 ,MV_PMA_BOOT_FATAL =BIT (0 ),
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 7/18 net: phy: marvell10g: support all rate matching modes
In reply to Marek BehúnAdd support for all rate matching modes for 88X3310 (currently only 10gbase-r is supported, but xaui and rxaui can also be used).
Add support for rate matching for 88E2110 (on 88E2110 the MACTYPE register is at a different place).
--- drivers/net/phy/marvell10g.c | 104 +++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 11 deletions(-)
drivers/net/phy/marvell10g.c +93 -11
@@ -108,14 +108,26 @@ enum { MV_V2_TEMP_UNKNOWN = 0x9600, /* unknown function */ }; +struct mv3310_chip { +int (*get_mactype)(struct phy_device *phydev); +int (*init_interface)(struct phy_device *phydev,int mactype); +}; +struct mv3310_priv {u32 firmware_ver;bool rate_match; +phy_interface_t const_interface;struct device *hwmon_dev;char *hwmon_name; }; +static inline const struct mv3310_chip * +to_mv3310_chip (struct phy_device *phydev) +{ +return phydev->drv->driver_data; +} +#ifdef CONFIG_HWMON static umode_t mv3310_hwmon_is_visible(const void *data, enum hwmon_sensor_types type,
@@ -470,11 +482,67 @@ static bool mv3310_has_pma_ngbaset_quirk(struct phy_device *phydev) MV_PHY_ALASKA_NBT_QUIRK_MASK) == MV_PHY_ALASKA_NBT_QUIRK_REV; } -static int mv3310_config_init (struct phy_device *phydev) +static int mv2110_get_mactype (struct phy_device *phydev) +{ +int mactype; + + mactype =phy_read_mmd (phydev,MDIO_MMD_PMAPMD ,MV_PMA_21X0_PORT_CTRL ); +if (mactype <0 ) +return mactype; + +return mactype &MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK ; +} + +static int mv3310_get_mactype (struct phy_device *phydev) +{ +int mactype; + + mactype =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL ); +if (mactype <0 ) +return mactype; + +return mactype &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ; +} + +static int mv2110_init_interface (struct phy_device *phydev,int mactype) {struct mv3310_priv *priv =dev_get_drvdata (&phydev->mdio.dev); -int err; -int val; + + priv->rate_match = false; + +if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) { + priv->rate_match = true; + priv->const_interface =PHY_INTERFACE_MODE_10GBASER ; + } + +return 0 ; +} + +static int mv3310_init_interface (struct phy_device *phydev,int mactype) +{ +struct mv3310_priv *priv =dev_get_drvdata (&phydev->mdio.dev); + + priv->rate_match = false; + +if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH || + mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH || + mactype ==MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH ) + priv->rate_match = true; + +if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) + priv->const_interface =PHY_INTERFACE_MODE_10GBASER ; +else if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH ) + priv->const_interface =PHY_INTERFACE_MODE_RXAUI ; +else if (mactype ==MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH ) + priv->const_interface =PHY_INTERFACE_MODE_XAUI ; + +return 0 ; +} + +static int mv3310_config_init (struct phy_device *phydev) +{ +const struct mv3310_chip *chip =to_mv3310_chip (phydev); +int err, mactype;/* Check that the PHY interface type is compatible */ if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
@@ -493,11 +561,13 @@ static int mv3310_config_init(struct phy_device *phydev)if (err)return err; - val =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL ); -if (val <0 ) -return val; - priv->rate_match = ((val &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ) == -MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ); + mactype = chip->get_mactype (phydev); +if (mactype <0 ) +return mactype; + + err = chip->init_interface (phydev, mactype); +if (err) +return err;/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
@@ -607,12 +677,12 @@ static void mv3310_update_interface(struct phy_device *phydev) {struct mv3310_priv *priv =dev_get_drvdata (&phydev->mdio.dev); -/* In "XFI with Rate Matching" mode the PHY interface is fixed at -* 10Gb. The PHY adapts the rate to actual wire speed with help of +/* In all of the "* with Rate Matching" modes the PHY interface is fixed +* at 10Gb. The PHY adapts the rate to actual wire speed with help of * internal 16KB buffer. */ if (priv->rate_match) { - phydev->interface =PHY_INTERFACE_MODE_10GBASER ; + phydev->interface = priv->const_interface;return ; }
@@ -788,11 +858,22 @@ static int mv3310_set_tunable(struct phy_device *phydev, } } +static const struct mv3310_chip mv3310_type = { + .get_mactype = mv3310_get_mactype, + .init_interface = mv3310_init_interface, +}; + +static const struct mv3310_chip mv2110_type = { + .get_mactype = mv2110_get_mactype, + .init_interface = mv2110_init_interface, +}; +static struct phy_driver mv3310_drivers[] = { { .phy_id =MARVELL_PHY_ID_88X3310 , .phy_id_mask =MARVELL_PHY_ID_MASK , .name ="mv88x3310" , + .driver_data = &mv3310_type, .get_features = mv3310_get_features, .config_init = mv3310_config_init, .probe = mv3310_probe,
@@ -810,6 +891,7 @@ static struct phy_driver mv3310_drivers[] = { .phy_id = MARVELL_PHY_ID_88E2110, .phy_id_mask = MARVELL_PHY_ID_MASK, .name = "mv88x2110", + .driver_data = &mv2110_type, .probe = mv3310_probe, .suspend = mv3310_suspend, .resume = mv3310_resume,
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 8/18 include: add library helpers for variadic macro expansion
In reply to Marek BehúnAdd a library with useful helpers to expand variadic macros.
We have the macro DECLARE_BITMAP(name, bits), but no way of compile-time initialization of such bitmaps. Since C does not support consteval functions, this can only be done via macros.
This macro library can be (among other things) used to implement a sane way for compile-time bitmap initialization, something like
static DECLARE_BITMAP(bm, 100) = INITIALIZE_BITMAP(100, 7, 9, 66, 98);
--- include/linux/variadic-macro.h | 221 +++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 include/linux/variadic-macro.h
include/linux/variadic-macro.h new file +221 -0
@@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Helpers for expanding variadic macros in useful ways +* +* 2021 by Marek Behún <[email protected]> +*/ + +#ifndef __VARIADIC_MACRO_H__ +#define __VARIADIC_MACRO_H__ + +/* +* Helpers for variadic macros with up to 32 arguments. +* Pretty simple to extend. +*/ + +#define _VM_GET_NTH_ARG (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, \ + _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, \ + _27, _28, _29, _30, _31, _32,N , ...) N + +#define _VM_HELP_0 (_f, _d, ...) +#define _VM_HELP_1 (_f, _d, x, ...) _f(x, _d) +#define _VM_HELP_2 (_f, _d, x, ...) _f(x, _d) _VM_HELP_1(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_3 (_f, _d, x, ...) _f(x, _d) _VM_HELP_2(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_4 (_f, _d, x, ...) _f(x, _d) _VM_HELP_3(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_5 (_f, _d, x, ...) _f(x, _d) _VM_HELP_4(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_6 (_f, _d, x, ...) _f(x, _d) _VM_HELP_5(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_7 (_f, _d, x, ...) _f(x, _d) _VM_HELP_6(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_8 (_f, _d, x, ...) _f(x, _d) _VM_HELP_7(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_9 (_f, _d, x, ...) _f(x, _d) _VM_HELP_8(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_10 (_f, _d, x, ...) _f(x, _d) _VM_HELP_9(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_11 (_f, _d, x, ...) _f(x, _d) _VM_HELP_10(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_12 (_f, _d, x, ...) _f(x, _d) _VM_HELP_11(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_13 (_f, _d, x, ...) _f(x, _d) _VM_HELP_12(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_14 (_f, _d, x, ...) _f(x, _d) _VM_HELP_13(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_15 (_f, _d, x, ...) _f(x, _d) _VM_HELP_14(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_16 (_f, _d, x, ...) _f(x, _d) _VM_HELP_15(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_17 (_f, _d, x, ...) _f(x, _d) _VM_HELP_16(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_18 (_f, _d, x, ...) _f(x, _d) _VM_HELP_17(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_19 (_f, _d, x, ...) _f(x, _d) _VM_HELP_18(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_20 (_f, _d, x, ...) _f(x, _d) _VM_HELP_19(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_21 (_f, _d, x, ...) _f(x, _d) _VM_HELP_20(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_22 (_f, _d, x, ...) _f(x, _d) _VM_HELP_21(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_23 (_f, _d, x, ...) _f(x, _d) _VM_HELP_22(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_24 (_f, _d, x, ...) _f(x, _d) _VM_HELP_23(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_25 (_f, _d, x, ...) _f(x, _d) _VM_HELP_24(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_26 (_f, _d, x, ...) _f(x, _d) _VM_HELP_25(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_27 (_f, _d, x, ...) _f(x, _d) _VM_HELP_26(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_28 (_f, _d, x, ...) _f(x, _d) _VM_HELP_27(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_29 (_f, _d, x, ...) _f(x, _d) _VM_HELP_28(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_30 (_f, _d, x, ...) _f(x, _d) _VM_HELP_29(_f, _d, ##__VA_ARGS__) +#define _VM_HELP_31 (_f, _d, x, ...) _f(x, _d) _VM_HELP_30(_f, _d, ##__VA_ARGS__) + +/* +* EXPAND_FOR_EACH(_functor, _data, args...) - expand a call to functor for +* each argument +* @_functor: name of the functor to expand a call to +* @_data: private data to apply to the functor +* @args...: for each of these arguments a call to functor will be expanded +* +* This macro will expand to a call to _functor(arg, _data) for all arguments +* after the _data argument, i.e. +* EXPAND_FOR_EACH(f, d, 1, 2, 3) +* will expand to +* f(1, d) f(2, d) f(3, d) +* +* ATTENTION: the functor cannot call EXPAND_FOR_EACH again. +* For recursive calls to EXPAND_FOR_EACH to be allowed, use EXPAND_FOR_EACH_R +* together with EXPAND_EVAL. +* Or you can call EXPAND_FOR_EACH in the functor for EXPAND_FOR_EACH_PASS_ARGS. +* +* Example: +* +* :: +* +* #define __BIT_OR(x, dummy) | BIT(x) +* #define BIT_OR(...) (0 EXPAND_FOR_EACH(__BIT_OR, dummy, ##__VA_ARGS__)) +* +* int x = BIT_OR(1, 7, 9, 13); +* assert(x == (BIT(1) | BIT(7) | BIT(9) | BIT(13))); +*/ +#define EXPAND_FOR_EACH (_functor, _data, ...) \ + _VM_GET_NTH_ARG("", ##__VA_ARGS__, _VM_HELP_31, _VM_HELP_30, \ + _VM_HELP_29, _VM_HELP_28, _VM_HELP_27, _VM_HELP_26, _VM_HELP_25, \ + _VM_HELP_24, _VM_HELP_23, _VM_HELP_22, _VM_HELP_21, _VM_HELP_20, \ + _VM_HELP_19, _VM_HELP_18, _VM_HELP_17, _VM_HELP_16, _VM_HELP_15, \ + _VM_HELP_14, _VM_HELP_13, _VM_HELP_12, _VM_HELP_11, _VM_HELP_10, \ + _VM_HELP_9, _VM_HELP_8, _VM_HELP_7, _VM_HELP_6, _VM_HELP_5, \ + _VM_HELP_4, _VM_HELP_3, _VM_HELP_2, _VM_HELP_1, \ + _VM_HELP_0)(_functor, _data, ##__VA_ARGS__) + +/* +* Black magic to prevent macros from creating disabling contexts +*/ +#define _VM_EMPTY (...) +#define _VM_DEFER (...) __VA_ARGS__ _VM_EMPTY() + +#define EXPAND_EVAL (...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__))) +#define _VM_EVAL1 (...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__))) +#define _VM_EVAL2 (...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__))) +#define _VM_EVAL3 (...) __VA_ARGS__ + +#define _VM_APPLY (x, _functor, _data, ...) _functor(x, _data, ##__VA_ARGS__) +#define _VM_APPLY_INDIRECT () _VM_APPLY +#define _VM_APPLY_HELPER (x, __args) \ + _VM_DEFER(_VM_APPLY_INDIRECT)()(x, _VM_DEFER __args) + +#define _VM_EXPAND_FOR_EACH_INDIRECT () EXPAND_FOR_EACH + +/* +* EXPAND_FOR_EACH_R(_functor, _data, args...) - expand a call to functor for +* each argument, recursive calls +* allowed +* @_functor: name of the functor to expand a call to +* @_data: private data to apply to the functor +* @args...: for each of these arguments a call to functor will be expanded +* +* Does the same as EXPAND_FOR_EACH(_functor, _data, args...), but _functor is +* allowed to call EXPAND_FOR_EACH_R again. +* +* ATTENTION: in order for this to work, the outermost call to this macro must +* be wrapped inside the EXPAND_EVAL macro. +* +* Example: +* +* :: +* +* #define EXP_3(y, x) x ## y +* #define EXP_2(x, ...) EXPAND_FOR_EACH_R(EXP_3, x, ##__VA_ARGS__) +* #define EXP_1(x, dummy) EXP_2(x, 1, 2, 3) +* #define EXP(...) EXPAND_EVAL(EXPAND_FOR_EACH_R(EXP_1, dummy, ##__VA_ARGS__)) +* +* EXP(a, b, c) +* // expands to: a1 a2 a3 b1 b2 b3 c1 c2 c3 +*/ +#define EXPAND_FOR_EACH_R _VM_DEFER(_VM_EXPAND_FOR_EACH_INDIRECT)() + +#define _VM_EXPAND_FOR_EACH_PASS_ARGS (_functor, _data, ...) \ + _VM_DEFER(_VM_EXPAND_FOR_EACH_INDIRECT)()(_VM_APPLY_HELPER, \ + (_functor, _data, ##__VA_ARGS__), ##__VA_ARGS__) + +/* +* EXPAND_FOR_EACH_PASS_ARGS(_functor, _data, args...) - +* expand a call to functor for each argument, pass all arguments to each call +* @_functor: name of the functor to expand a call to +* @_data: private data to apply to the functor +* @args...: for each of these arguments a call to functor will be expanded +* +* For each argument after the _data argument, a call to +* _functor(arg, _data, args...) will be expanded. +* This is similar to EXPAND_FOR_EACH, but each expanded call will also be +* passed all the original arguments, i.e. +* EXPAND_FOR_EACH_PASS_ARGS(f, d, 1, 2, 3) +* will expand to +* f(1, d, 1, 2, 3) f(2, d, 1, 2, 3) f(3, d, 1, 2, 3) +* +* This is useful when one needs to call EXPAND_FOR_EACH in the functor again, +* to expand all the arguments in some way for each argument. +* +* ATTENTION: the functor cannot call EXPAND_FOR_EACH_PASS_ARGS again. +* For recursive calls to EXPAND_FOR_EACH_PASS_ARGS to be allowed, use +* EXPAND_FOR_EACH_PASS_ARGS_R together with EXPAND_EVAL. +* +* Example (a mechanism to compile time bitmap initialization): +* +* :: +* +* #define __BIT_OR(x, dummy) | BIT(x) +* #define BIT_OR(...) (0 EXPAND_FOR_EACH(__BIT_OR, dummy, ##__VA_ARGS__)) +* #define BM_MEMB(bit) ((bit) / BITS_PER_LONG) +* #define BM_OR(bit, member) \ +* | (BM_MEMB(bit) == member ? BIT((bit) % BITS_PER_LONG) : 0) +* #define INIT_BITMAP_MEMBER(bit, dummy, ...) \ +* [BM_MEMB(bit)] = (0 EXPAND_FOR_EACH(BM_OR, BM_MEMB(bit), ##__VA_ARGS__)), +* #define INIT_BITMAP(...) \ +* { \ +* EXPAND_FOR_EACH_PASS_ARGS(INIT_BITMAP_MEMBER, dummy, ##__VA_ARGS__) \ +* } +* +* static const DECLARE_BITMAP(bm, 90) = +* INIT_BITMAP(1, 2, 15, 32, 36, 80); +*/ +#define EXPAND_FOR_EACH_PASS_ARGS (_functor, _data, ...) \ + EXPAND_EVAL(_VM_EXPAND_FOR_EACH_PASS_ARGS(_functor, \ + _data, ##__VA_ARGS__)) + +#define _VM_EXPAND_FOR_EACH_PASS_ARGS_INDIRECT () _VM_EXPAND_FOR_EACH_PASS_ARGS + +/* +* EXPAND_FOR_EACH_PASS_ARGS_R(_functor, _data, args...) - +* expand a call to functor for each argument, pass all arguments to each +* call, recursive calls allowed +* @_functor: name of the functor to expand a call to +* @_data: private data to apply to the functor +* @args...: for each of these arguments a call to functor will be expanded +* +* Does the same as EXPAND_FOR_EACH_PASS_ARGS(_functor, _data, args...), but +* _functor is allowed to call EXPAND_FOR_EACH_PASS_ARGS_R again. +* +* ATTENTION: in order for this to work, the outermost call to this macro must +* be wrapped inside the EXPAND_EVAL macro. +* +* Example: +* +* :: +* +* #define EXP_4(xy, z) z ## xy +* #define EXP_3(y, x, ...) EXPAND_FOR_EACH(EXP_4, x ## y, ##__VA_ARGS__) +* #define EXP_2(x, ...) EXPAND_FOR_EACH_PASS_ARGS_R(EXP_3, x, ##__VA_ARGS__) +* #define EXP_1(x, dummy, ...) EXP_2(x, __VA_ARGS__) +* #define EXP(...) \ +* EXPAND_EVAL(EXPAND_FOR_EACH_PASS_ARGS_R(EXP_1, dummy, ##__VA_ARGS__)) +* +* EXP(a, b, c) +* // expands to: aaa aab aac aba abb abc aca acb acc +* // baa bab bac bba bbb bbc bca bcb bcc +* // caa cab cac cba cbb cbc cca ccb ccc +*/ +#define EXPAND_FOR_EACH_PASS_ARGS_R \ + _VM_DEFER(_VM_EXPAND_FOR_EACH_PASS_ARGS_INDIRECT)() + +#endif /* __VARIADIC_MACRO_H__ */
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 9/18 include: bitmap: add macro for bitmap initialization
In reply to Marek BehúnUse the new variadic-macro.h library to implement macro INITIALIZE_BITMAP(nbits, ...), which can be used for compile time bitmap initialization in the form
static DECLARE_BITMAP(bm, 100) = INITIALIZE_BITMAP(100, 7, 9, 66, 98);
The macro uses the BUILD_BUG_ON_ZERO mechanism to ensure a compile-time error if an argument is out of range.
--- include/linux/bitmap.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
include/linux/bitmap.h +24 -0
@@ -8,6 +8,7 @@#include <linux/bitops.h> #include <linux/string.h> #include <linux/kernel.h> +#include <linux/variadic-macro.h> /* * bitmaps provide bit arrays that consume one or more unsigned
@@ -114,6 +115,29 @@* contain all bit positions from 0 to 'bits' - 1. */ +/** +* DOC: initialize bitmap +* The INITIALIZE_BITMAP(bits, args...) macro expands to a designated +* initializer for bitmap of length 'bits', setting each bit specified +* in 'args...'. +*/ +#define _BIT_MEMBER (bit) ((bit) / BITS_PER_LONG) +#define _VERIFY_BIT (bit, nbits) \ + BUILD_BUG_ON_ZERO((bit) < 0 || (bit) >= (nbits)) +#define _INIT_BITMAP_MEMBER_VALUE (bit, member_bit) \ + | (_BIT_MEMBER(bit) == _BIT_MEMBER(member_bit) \ + ? BIT((bit) % BITS_PER_LONG) \ + : 0) +#define _INIT_BITMAP_MEMBER (bit, nbits, ...) \ + [_VERIFY_BIT((bit), (nbits)) + _BIT_MEMBER(bit)] = \ + (0 EXPAND_FOR_EACH(_INIT_BITMAP_MEMBER_VALUE, \ + (bit), ##__VA_ARGS__)), +#define INITIALIZE_BITMAP (nbits, ...) \ + { \ + EXPAND_FOR_EACH_PASS_ARGS(_INIT_BITMAP_MEMBER, (nbits), \ + ##__VA_ARGS__) \ + } +/* * Allocation and deallocation of bitmap. * Provided in lib/bitmap.c to avoid circular dependency.
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 10/18 net: phy: marvell10g: check for correct supported interface mode
In reply to Marek BehúnThe 88E2110 does not support xaui nor rxaui modes. Check for correct interface mode for different chips.
--- drivers/net/phy/marvell10g.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/phy/marvell10g.c +18 -7
@@ -109,6 +109,7 @@ enum { };struct mv3310_chip { + DECLARE_BITMAP(supported_interfaces, PHY_INTERFACE_MODE_MAX);int (*get_mactype)(struct phy_device *phydev);int (*init_interface)(struct phy_device *phydev,int mactype); };
@@ -545,13 +546,7 @@ static int mv3310_config_init(struct phy_device *phydev)int err, mactype;/* Check that the PHY interface type is compatible */ -if (phydev->interface !=PHY_INTERFACE_MODE_SGMII && - phydev->interface !=PHY_INTERFACE_MODE_2500BASEX && - phydev->interface !=PHY_INTERFACE_MODE_5GBASER && - phydev->interface !=PHY_INTERFACE_MODE_XAUI && - phydev->interface !=PHY_INTERFACE_MODE_RXAUI && - phydev->interface !=PHY_INTERFACE_MODE_10GBASER && - phydev->interface !=PHY_INTERFACE_MODE_USXGMII ) +if (!test_bit (phydev->interface, chip->supported_interfaces))return -ENODEV ; phydev->mdix_ctrl =ETH_TP_MDI_AUTO ;
@@ -859,11 +854,27 @@ static int mv3310_set_tunable(struct phy_device *phydev, }static const struct mv3310_chip mv3310_type = { + .supported_interfaces = +INITIALIZE_BITMAP (PHY_INTERFACE_MODE_MAX , +PHY_INTERFACE_MODE_SGMII , +PHY_INTERFACE_MODE_2500BASEX , +PHY_INTERFACE_MODE_5GBASER , +PHY_INTERFACE_MODE_XAUI , +PHY_INTERFACE_MODE_RXAUI , +PHY_INTERFACE_MODE_10GBASER , +PHY_INTERFACE_MODE_USXGMII ), .get_mactype = mv3310_get_mactype, .init_interface = mv3310_init_interface, };static const struct mv3310_chip mv2110_type = { + .supported_interfaces = +INITIALIZE_BITMAP (PHY_INTERFACE_MODE_MAX , +PHY_INTERFACE_MODE_SGMII , +PHY_INTERFACE_MODE_2500BASEX , +PHY_INTERFACE_MODE_5GBASER , +PHY_INTERFACE_MODE_10GBASER , +PHY_INTERFACE_MODE_USXGMII ), .get_mactype = mv2110_get_mactype, .init_interface = mv2110_init_interface, };
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 11/18 net: phy: marvell10g: store temperature read method in chip strucutre
In reply to Marek BehúnNow that we have a chip structure, we can store the temperature reading method in this structure (OOP style).
--- drivers/net/phy/marvell10g.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/phy/marvell10g.c +14 -9
@@ -112,6 +112,10 @@ struct mv3310_chip {DECLARE_BITMAP (supported_interfaces,PHY_INTERFACE_MODE_MAX );int (*get_mactype)(struct phy_device *phydev);int (*init_interface)(struct phy_device *phydev,int mactype); + +#ifdef CONFIG_HWMON +int (*hwmon_read_temp_reg)(struct phy_device *phydev); +#endif };struct mv3310_priv {
@@ -151,18 +155,11 @@ static int mv2110_hwmon_read_temp_reg(struct phy_device *phydev)return phy_read_mmd (phydev,MDIO_MMD_PCS ,MV_PCS_TEMP ); } -static int mv10g_hwmon_read_temp_reg (struct phy_device *phydev) -{ -if (phydev->drv->phy_id ==MARVELL_PHY_ID_88X3310 ) -return mv3310_hwmon_read_temp_reg (phydev); -else /* MARVELL_PHY_ID_88E2110 */ -return mv2110_hwmon_read_temp_reg (phydev); -} -static int mv3310_hwmon_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long *value) {struct phy_device *phydev =dev_get_drvdata (dev); +const struct mv3310_chip *chip =to_mv3310_chip (phydev);int temp;if (type == hwmon_chip && attr == hwmon_chip_update_interval) {
@@ -171,7 +168,7 @@ static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type, }if (type == hwmon_temp && attr == hwmon_temp_input) { - temp =mv10g_hwmon_read_temp_reg (phydev); + temp = chip->hwmon_read_temp_reg (phydev);if (temp <0 )return temp;
@@ -865,6 +862,10 @@ static const struct mv3310_chip mv3310_type = { PHY_INTERFACE_MODE_USXGMII), .get_mactype = mv3310_get_mactype, .init_interface = mv3310_init_interface, + +#ifdef CONFIG_HWMON + .hwmon_read_temp_reg = mv3310_hwmon_read_temp_reg, +#endif }; static const struct mv3310_chip mv2110_type = {
@@ -877,6 +878,10 @@ static const struct mv3310_chip mv2110_type = { PHY_INTERFACE_MODE_USXGMII), .get_mactype = mv2110_get_mactype, .init_interface = mv2110_init_interface, + +#ifdef CONFIG_HWMON + .hwmon_read_temp_reg = mv2110_hwmon_read_temp_reg, +#endif }; static struct phy_driver mv3310_drivers[] = {
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 12/18 net: phy: marvell10g: support other MACTYPEs
In reply to Marek BehúnCurrently the only "changing" MACTYPE we support is when the PHY changes between
10gbase-r / 5gbase-r / 2500base-x / sgmii
Add support for
usxgmii
xaui / 5gbase-r / 2500base-x / sgmii
rxaui / 5gbase-r / 2500base-x / sgmii
and also
5gbase-r / 2500base-x / sgmii
for 88E2110.
--- drivers/net/phy/marvell10g.c | 90 +++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 36 deletions(-)
drivers/net/phy/marvell10g.c +54 -36
@@ -508,10 +508,18 @@ static int mv2110_init_interface(struct phy_device *phydev, int mactype) priv->rate_match = false; -if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) { +if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) priv->rate_match = true; + +if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII ) + priv->const_interface =PHY_INTERFACE_MODE_USXGMII ; +else if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) priv->const_interface =PHY_INTERFACE_MODE_10GBASER ; - } +else if (mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER || + mactype ==MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN ) + priv->const_interface =PHY_INTERFACE_MODE_NA ; +else +return -EINVAL ;return 0 ; }
@@ -527,12 +535,20 @@ static int mv3310_init_interface(struct phy_device *phydev, int mactype) mactype == MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH) priv->rate_match = true; -if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH ) +if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII ) + priv->const_interface =PHY_INTERFACE_MODE_USXGMII ; +else if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH || + mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN || + mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER ) priv->const_interface =PHY_INTERFACE_MODE_10GBASER ; -else if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH ) +else if (mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH || + mactype ==MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI ) priv->const_interface =PHY_INTERFACE_MODE_RXAUI ; -else if (mactype ==MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH ) +else if (mactype ==MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH || + mactype ==MV_V2_3310_PORT_CTRL_MACTYPE_XAUI ) priv->const_interface =PHY_INTERFACE_MODE_XAUI ; +else +return -EINVAL ;return 0 ; }
@@ -558,8 +574,10 @@ static int mv3310_config_init(struct phy_device *phydev)return mactype; err = chip->init_interface (phydev, mactype); -if (err) +if (err) { +phydev_err (phydev,"MACTYPE configuration invalid\n" );return err; + }/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
@@ -669,44 +687,44 @@ static void mv3310_update_interface(struct phy_device *phydev) {struct mv3310_priv *priv =dev_get_drvdata (&phydev->mdio.dev); +if (!phydev->link) +return ; +/* In all of the "* with Rate Matching" modes the PHY interface is fixed * at 10Gb. The PHY adapts the rate to actual wire speed with help of * internal 16KB buffer. +* +* In USXGMII mode the PHY interface mode is also fixed. */ -if (priv->rate_match) { +if (priv->rate_match || + priv->const_interface ==PHY_INTERFACE_MODE_USXGMII ) { phydev->interface = priv->const_interface;return ; } -if ((phydev->interface ==PHY_INTERFACE_MODE_SGMII || - phydev->interface ==PHY_INTERFACE_MODE_2500BASEX || - phydev->interface ==PHY_INTERFACE_MODE_5GBASER || - phydev->interface ==PHY_INTERFACE_MODE_10GBASER ) && - phydev->link) { -/* The PHY automatically switches its serdes interface (and -* active PHYXS instance) between Cisco SGMII, 10GBase-R and -* 2500BaseX modes according to the speed. Florian suggests -* setting phydev->interface to communicate this to the MAC. -* Only do this if we are already in one of the above modes. -*/ -switch (phydev->speed) { -case SPEED_10000 : - phydev->interface =PHY_INTERFACE_MODE_10GBASER ; -break ; -case SPEED_5000 : - phydev->interface =PHY_INTERFACE_MODE_5GBASER ; -break ; -case SPEED_2500 : - phydev->interface =PHY_INTERFACE_MODE_2500BASEX ; -break ; -case SPEED_1000 : -case SPEED_100 : -case SPEED_10 : - phydev->interface =PHY_INTERFACE_MODE_SGMII ; -break ; -default : -break ; - } +/* The PHY automatically switches its serdes interface (and active PHYXS +* instance) between Cisco SGMII, 2500BaseX, 5GBase-R and 10GBase-R / +* xaui / rxaui modes according to the speed. +* Florian suggests setting phydev->interface to communicate this to the +* MAC. Only do this if we are already in one of the above modes. +*/ +switch (phydev->speed) { +case SPEED_10000 : + phydev->interface = priv->const_interface; +break ; +case SPEED_5000 : + phydev->interface =PHY_INTERFACE_MODE_5GBASER ; +break ; +case SPEED_2500 : + phydev->interface =PHY_INTERFACE_MODE_2500BASEX ; +break ; +case SPEED_1000 : +case SPEED_100 : +case SPEED_10 : + phydev->interface =PHY_INTERFACE_MODE_SGMII ; +break ; +default : +break ; } }
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 13/18 net: phy: marvell10g: add separate structure for 88X3340
In reply to Marek BehúnThe 88X3340 contains 4 cores similar to 88X3310, but there is a
difference: it does not support xaui host mode. Instead the corresponding MACTYPE means
rxaui / 5gbase-r / 2500base-x / sgmii without AN
--- drivers/net/phy/marvell10g.c | 55 ++++++++++++++++++++++++++++++++++-- include/linux/marvell_phy.h | 6 +++- 2 files changed, 58 insertions(+), 3 deletions(-)
drivers/net/phy/marvell10g.c +53 -2
@@ -553,6 +553,21 @@ static int mv3310_init_interface(struct phy_device *phydev, int mactype)return 0 ; } +static int mv3340_init_interface (struct phy_device *phydev,int mactype) +{ +struct mv3310_priv *priv =dev_get_drvdata (&phydev->mdio.dev); +int err =0 ; + + priv->rate_match = false; + +if (mactype ==MV_V2_3340_PORT_CTRL_MACTYPE_RXAUI_NO_SGMII_AN ) + priv->const_interface =PHY_INTERFACE_MODE_RXAUI ; +else + err =mv3310_init_interface (phydev, mactype); + +return err; +} +static int mv3310_config_init (struct phy_device *phydev) {const struct mv3310_chip *chip =to_mv3310_chip (phydev);
@@ -886,6 +901,23 @@ static const struct mv3310_chip mv3310_type = {#endif }; +static const struct mv3310_chip mv3340_type = { + .supported_interfaces = +INITIALIZE_BITMAP (PHY_INTERFACE_MODE_MAX , +PHY_INTERFACE_MODE_SGMII , +PHY_INTERFACE_MODE_2500BASEX , +PHY_INTERFACE_MODE_5GBASER , +PHY_INTERFACE_MODE_RXAUI , +PHY_INTERFACE_MODE_10GBASER , +PHY_INTERFACE_MODE_USXGMII ), + .get_mactype = mv3310_get_mactype, + .init_interface = mv3340_init_interface, + +#ifdef CONFIG_HWMON + .hwmon_read_temp_reg = mv3310_hwmon_read_temp_reg, +#endif +}; +static const struct mv3310_chip mv2110_type = { .supported_interfaces = INITIALIZE_BITMAP(PHY_INTERFACE_MODE_MAX,
@@ -905,7 +937,7 @@ static const struct mv3310_chip mv2110_type = {static struct phy_driver mv3310_drivers[] = { { .phy_id =MARVELL_PHY_ID_88X3310 , - .phy_id_mask =MARVELL_PHY_ID_MASK , + .phy_id_mask =MARVELL_PHY_ID_88X33X0_MASK , .name ="mv88x3310" , .driver_data = &mv3310_type, .get_features = mv3310_get_features,
@@ -921,6 +953,24 @@ static struct phy_driver mv3310_drivers[] = { .remove = mv3310_remove, .set_loopback = genphy_c45_loopback, }, + { + .phy_id = MARVELL_PHY_ID_88X3340, + .phy_id_mask = MARVELL_PHY_ID_88X33X0_MASK, + .name = "mv88x3340", + .driver_data = &mv3340_type, + .get_features = mv3310_get_features, + .config_init = mv3310_config_init, + .probe = mv3310_probe, + .suspend = mv3310_suspend, + .resume = mv3310_resume, + .config_aneg = mv3310_config_aneg, + .aneg_done = mv3310_aneg_done, + .read_status = mv3310_read_status, + .get_tunable = mv3310_get_tunable, + .set_tunable = mv3310_set_tunable, + .remove = mv3310_remove, + .set_loopback = genphy_c45_loopback, + }, { .phy_id = MARVELL_PHY_ID_88E2110, .phy_id_mask = MARVELL_PHY_ID_MASK,
@@ -943,7 +993,8 @@ static struct phy_driver mv3310_drivers[] = {module_phy_driver (mv3310_drivers);static struct mdio_device_id __maybe_unused mv3310_tbl[] = { - {MARVELL_PHY_ID_88X3310 ,MARVELL_PHY_ID_MASK }, + {MARVELL_PHY_ID_88X3310 ,MARVELL_PHY_ID_88X33X0_MASK }, + {MARVELL_PHY_ID_88X3340 ,MARVELL_PHY_ID_88X33X0_MASK }, {MARVELL_PHY_ID_88E2110 ,MARVELL_PHY_ID_MASK }, { }, };
include/linux/marvell_phy.h +5 -1
@@ -22,10 +22,14 @@#define MARVELL_PHY_ID_88E1545 0x01410ea0#define MARVELL_PHY_ID_88E1548P 0x01410ec0#define MARVELL_PHY_ID_88E3016 0x01410e60 -#define MARVELL_PHY_ID_88X3310 0x002b09a0#define MARVELL_PHY_ID_88E2110 0x002b09b0#define MARVELL_PHY_ID_88X2222 0x01410f10 +/* PHY IDs and mask for Alaska 10G PHYs */ +#define MARVELL_PHY_ID_88X33X0_MASK 0xfffffff8 +#define MARVELL_PHY_ID_88X3310 0x002b09a0 +#define MARVELL_PHY_ID_88X3340 0x002b09a8 +/* Marvel 88E1111 in Finisar SFP module with modified PHY ID */ #define MARVELL_PHY_ID_88E1111_FINISAR 0x01ff0cc0
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 14/18 net: phy: marvell10g: fix driver name for mv88e2110
In reply to Marek BehúnThe driver name "mv88x2110" should be instead "mv88e2110".
--- drivers/net/phy/marvell10g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell10g.c +1 -1
@@ -974,7 +974,7 @@ static struct phy_driver mv3310_drivers[] = { { .phy_id = MARVELL_PHY_ID_88E2110, .phy_id_mask = MARVELL_PHY_ID_MASK, - .name = "mv88x2110", + .name = "mv88e2110", .driver_data = &mv2110_type, .probe = mv3310_probe, .suspend = mv3310_suspend,
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 15/18 net: phy: add constants for 2.5G and 5G speed in PCS speed register
In reply to Marek BehúnAdd constants for 2.5G and 5G speed in PCS speed register into mdio.h.
--- include/uapi/linux/mdio.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/linux/mdio.h +2 -0
@@ -120,6 +120,8 @@#define MDIO_PMA_SPEED_100 0x0020/* 100M capable */ #define MDIO_PMA_SPEED_10 0x0040/* 10M capable */ #define MDIO_PCS_SPEED_10P2B 0x0002/* 10PASS-TS/2BASE-TL capable */ +#define MDIO_PCS_SPEED_2_5G 0x0040/* 2.5G capable */ +#define MDIO_PCS_SPEED_5G 0x0080/* 5G capable */ /* Device present registers. */ #define MDIO_DEVS_PRESENT (devad) (1 << (devad))
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 16/18 net: phy: marvell10g: differentiate 88E2110 vs 88E2111
In reply to Marek Behún88E2111 is a variant of 88E2110 which does not support 5 gigabit speeds.
Differentiate these variants via the match_phy_device() method, since they have the same PHY ID.
--- drivers/net/phy/marvell10g.c | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/net/phy/marvell10g.c +59 -0
@@ -934,6 +934,46 @@ static const struct mv3310_chip mv2110_type = {#endif }; +static const struct mv3310_chip mv2111_type = { + .supported_interfaces = +INITIALIZE_BITMAP (PHY_INTERFACE_MODE_MAX , +PHY_INTERFACE_MODE_SGMII , +PHY_INTERFACE_MODE_2500BASEX , +PHY_INTERFACE_MODE_10GBASER , +PHY_INTERFACE_MODE_USXGMII ), + .get_mactype = mv2110_get_mactype, + .init_interface = mv2110_init_interface, + +#ifdef CONFIG_HWMON + .hwmon_read_temp_reg = mv2110_hwmon_read_temp_reg, +#endif +}; + +static int mv211x_match_phy_device (struct phy_device *phydev,bool has_5g) +{ +int val; + +if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD ] & +MARVELL_PHY_ID_MASK ) !=MARVELL_PHY_ID_88E2110 ) +return 0 ; + + val =phy_read_mmd (phydev,MDIO_MMD_PCS ,MDIO_SPEED ); +if (val <0 ) +return val; + +return !!(val &MDIO_PCS_SPEED_5G ) == has_5g; +} + +static int mv2110_match_phy_device (struct phy_device *phydev) +{ +return mv211x_match_phy_device (phydev, true); +} + +static int mv2111_match_phy_device (struct phy_device *phydev) +{ +return mv211x_match_phy_device (phydev, false); +} +static struct phy_driver mv3310_drivers[] = { { .phy_id =MARVELL_PHY_ID_88X3310 ,
@@ -974,6 +1014,7 @@ static struct phy_driver mv3310_drivers[] = { { .phy_id = MARVELL_PHY_ID_88E2110, .phy_id_mask = MARVELL_PHY_ID_MASK, + .match_phy_device = mv2110_match_phy_device, .name = "mv88e2110", .driver_data = &mv2110_type, .probe = mv3310_probe,
@@ -988,6 +1029,24 @@ static struct phy_driver mv3310_drivers[] = { .remove = mv3310_remove, .set_loopback = genphy_c45_loopback, }, + { + .phy_id = MARVELL_PHY_ID_88E2110, + .phy_id_mask = MARVELL_PHY_ID_MASK, + .match_phy_device = mv2111_match_phy_device, + .name = "mv88e2111", + .driver_data = &mv2111_type, + .probe = mv3310_probe, + .suspend = mv3310_suspend, + .resume = mv3310_resume, + .config_init = mv3310_config_init, + .config_aneg = mv3310_config_aneg, + .aneg_done = mv3310_aneg_done, + .read_status = mv3310_read_status, + .get_tunable = mv3310_get_tunable, + .set_tunable = mv3310_set_tunable, + .remove = mv3310_remove, + .set_loopback = genphy_c45_loopback, + }, };module_phy_driver (mv3310_drivers);
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 17/18 net: phy: marvell10g: change module description
In reply to Marek BehúnThis module supports not not only Alaska X, but also Alaska M.
Change module description appropriately.
--- drivers/net/phy/marvell10g.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell10g.c +1 -1
@@ -1058,5 +1058,5 @@ static struct mdio_device_id __maybe_unused mv3310_tbl[] = { { }, };MODULE_DEVICE_TABLE (mdio, mv3310_tbl); -MODULE_DESCRIPTION ("Marvell Alaska X 10Gigabit Ethernet PHY driver (MV88X3310)" ); +MODULE_DESCRIPTION ("Marvell Alaska X/M multi-gigabit Ethernet PHY driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.26.2
Marek Behún
maintainerPATCH v3 18/18 MAINTAINERS: add myself as maintainer of marvell10g driver
In reply to Marek BehúnAdd myself as maintainer of the marvell10g ethernet PHY driver, in addition to Russell King.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -10695,6 +10695,7 @@ F: include/linux/mv643xx.h MARVELL MV88X3310 PHY DRIVER M: Russell King <[email protected]> +M: Marek Behun <[email protected]> L: [email protected] S: Maintained F: drivers/net/phy/marvell10g.c
Signature · 1 line
2.26.2
Re: [PATCH net-next v3 01/18] net: phy: marvell10g: rename register
In reply to Marek BehúnQuoted 4 lines · Marek Behún
The MV_V2_PORT_MAC_TYPE_* is part of the CTRL register. Rename to MV_V2_PORT_CTRL_MACTYPE_*.
Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 02/18] net: phy: marvell10g: fix typo
In reply to Marek BehúnQuoted 3 lines · Marek Behún
This space should be a tab instead.
Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 03/18] net: phy: marvell10g: allow 5gbase-r and usxgmii
In reply to Marek BehúnQuoted 3 lines · Marek Behún
These modes are also supported by these PHYs.
Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 05/18] net: phy: marvell10g: add all MACTYPE definitions for 88X33x0
In reply to Marek BehúnQuoted 7 lines · Marek Behún
Add all MACTYPE definitions for 88X3310, 88X3310P, 88X3340 and 88X3340P.
In order to have consistent naming, rename
MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCHtoMV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH.Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 06/18] net: phy: marvell10g: add MACTYPE definitions for 88E21xx
In reply to Marek BehúnQuoted 3 lines · Marek Behún
Add all MACTYPE definitions for 88E2110, 88E2180, 88E2111 and 88E2181.
Signed-off-by Marek Behún <[email protected]>
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next v3 07/18] net: phy: marvell10g: support all rate matching modes
In reply to Marek Behúndrivers/net/phy/marvell10g.c enum { · line 129
Quoted 5 lines
drivers/net/phy/marvell10g.c +5
-0+static inline const struct mv3310_chip * +to_mv3310_chip (struct phy_device *phydev) +{ +return phydev->drv->driver_data; +}
No inline functions in C code please. Let the compiler decide.
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next v3 07/18] net: phy: marvell10g: support all rate matching modes
In reply to Marek BehúnQuoted 5 lines · Marek Behún
Add support for all rate matching modes for 88X3310 (currently only 10gbase-r is supported, but xaui and rxaui can also be used).
Add support for rate matching for 88E2110 (on 88E2110 the MACTYPE register is at a different place).
What is not clear to me is how rate matching mode gets enabled. What sets the mactype to one of these modes?
It probably just needs an explanation here in the commit message.
Andrew
Marek Behún
maintainerRe: [PATCH net-next v3 07/18] net: phy: marvell10g: support all rate matching modes
In reply to Andrew LunnQuoted 9 lines · On Wed, 7 Apr 2021 01:30:28 +0200 Andrew Lunn <[email protected]> wrote:
drivers/net/phy/marvell10g.c enum { · line 129
Quoted 5 lines
drivers/net/phy/marvell10g.c +5
-0+static inline const struct mv3310_chip * +to_mv3310_chip (struct phy_device *phydev) +{ +return phydev->drv->driver_data; +}No inline functions in C code please. Let the compiler decide.
Andrew
Fixed in my repo. Will send changed for v4.
Marek
Andrew Lunn
maintainerRe: [PATCH net-next v3 09/18] include: bitmap: add macro for bitmap initialization
In reply to Marek BehúnQuoted 26 lines · Marek Behún
Use the new
variadic-macro.hlibrary to implement macroINITIALIZE_BITMAP(nbits, ...), which can be used for compile time bitmap initialization in the form
staticDECLARE_BITMAP(bm, 100)=INITIALIZE_BITMAP(100, 7, 9, 66, 98);The macro uses the
BUILD_BUG_ON_ZEROmechanism to ensure a compile-time error if an argument is out of range.Signed-off-by Marek Behún <[email protected]>--- include/linux/bitmap.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)include/linux/bitmap.h +1
-0@@ -8,6 +8,7 @@#include <linux/bitops.h> #include <linux/string.h> #include <linux/kernel.h> +#include <linux/variadic-macro.h> /* * bitmaps provide bit arrays that consume one or more unsigned
include/linux/bitmap.h line 123
Quoted 9 lines
include/linux/bitmap.h +6
-0@@ -114,6 +115,29 @@* contain all bit positions from 0 to 'bits' - 1. */ +/** +* DOC: initialize bitmap +* The INITIALIZE_BITMAP(bits, args...) macro expands to a designated +* initializer for bitmap of length 'bits', setting each bit specified +* in 'args...'. +*/
Doesn't the /** mean this is kernel doc? The rest does not seem to follow kdoc. Does this compile cleanly with W=1?
Andrew
Re: [PATCH net-next v3 10/18] net: phy: marvell10g: check for correct supported interface mode
In reply to Marek BehúnQuoted 4 lines · Marek Behún
The 88E2110 does not support xaui nor rxaui modes. Check for correct interface mode for different chips.
Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 11/18] net: phy: marvell10g: store temperature read method in chip strucutre
In reply to Marek BehúnQuoted 4 lines · Marek Behún
Now that we have a chip structure, we can store the temperature reading method in this structure (OOP style).
Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 13/18] net: phy: marvell10g: add separate structure for 88X3340
In reply to Marek BehúnQuoted 6 lines · Marek Behún
The 88X3340 contains 4 cores similar to 88X3310, but there is a
difference: it does not support xaui host mode. Instead the corresponding MACTYPE means
rxaui / 5gbase-r / 2500base-x / sgmii without ANSigned-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 14/18] net: phy: marvell10g: fix driver name for mv88e2110
In reply to Marek BehúnQuoted 3 lines · Marek Behún
The driver name "mv88x2110" should be instead "mv88e2110".
Signed-off-by Marek Behún <[email protected]>
Andrew
Marek Behún
maintainerRe: [PATCH net-next v3 09/18] include: bitmap: add macro for bitmap initialization
In reply to Andrew LunnQuoted 40 lines · On Wed, 7 Apr 2021 01:38:30 +0200 Andrew Lunn <[email protected]> wrote:
Quoted 26 lines · Marek Behún
Use the new
variadic-macro.hlibrary to implement macroINITIALIZE_BITMAP(nbits, ...), which can be used for compile time bitmap initialization in the form
staticDECLARE_BITMAP(bm, 100)=INITIALIZE_BITMAP(100, 7, 9, 66, 98);The macro uses the
BUILD_BUG_ON_ZEROmechanism to ensure a compile-time error if an argument is out of range.Signed-off-by Marek Behún <[email protected]>--- include/linux/bitmap.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)include/linux/bitmap.h +1
-0@@ -8,6 +8,7 @@#include <linux/bitops.h> #include <linux/string.h> #include <linux/kernel.h> +#include <linux/variadic-macro.h> /* * bitmaps provide bit arrays that consume one or more unsigned include/linux/bitmap.h line 123
Quoted 9 lines
include/linux/bitmap.h +6
-0@@ -114,6 +115,29 @@* contain all bit positions from 0 to 'bits' - 1. */ +/** +* DOC: initialize bitmap +* The INITIALIZE_BITMAP(bits, args...) macro expands to a designated +* initializer for bitmap of length 'bits', setting each bit specified +* in 'args...'. +*/ Doesn't the /** mean this is kernel doc? The rest does not seem to follow kdoc. Does this compile cleanly with W=1?
Quoted 1 line
Andrew
Hmm. I just used the same style as was above in the same file, for /**
* DOC: declare bitmap
...
Anyway W=1 does not complain.
But it does complain about the implementation for INITIALIZE_BITMAP. It seems that we have to use -Wno-override-init.
This seems to be a new option for gcc. For clang, scripts/Makefile.extrawarn already uses -Wno-initializer-overrides, but we have to add -Wno-override-init for gcc.
Marek
Marek Behún
maintainerRe: [PATCH net-next v3 07/18] net: phy: marvell10g: support all rate matching modes
In reply to Andrew LunnQuoted 7 lines · On Wed, 7 Apr 2021 01:33:33 +0200 Andrew Lunn <[email protected]> wrote:
Quoted 5 lines · Marek Behún
Add support for all rate matching modes for 88X3310 (currently only 10gbase-r is supported, but xaui and rxaui can also be used).
Add support for rate matching for 88E2110 (on 88E2110 the MACTYPE register is at a different place).
Quoted 6 lines
What is not clear to me is how rate matching mode gets enabled. What sets the mactype to one of these modes?
It probably just needs an explanation here in the commit message.
Andrew
Currently MACTYPE is set via strapping pins. I will add this to the commit message for v4.
Both Russell King and myself are working on patches to support selecting correct/better MACTYPE from information about which interface modes are supported by the MAC and by the board. But first I want to get this merged.
Marek
Re: [PATCH net-next v3 15/18] net: phy: add constants for 2.5G and 5G speed in PCS speed register
In reply to Marek BehúnQuoted 3 lines · Marek Behún
Add constants for 2.5G and 5G speed in PCS speed register into
mdio.h.Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 16/18] net: phy: marvell10g: differentiate 88E2110 vs 88E2111
In reply to Marek BehúnQuoted 6 lines · Marek Behún
88E2111 is a variant of 88E2110 which does not support 5 gigabit speeds.
Differentiate these variants via the
match_phy_device()method, since they have the same PHY ID.Signed-off-by Marek Behún <[email protected]>
Andrew
Re: [PATCH net-next v3 17/18] net: phy: marvell10g: change module description
In reply to Marek BehúnQuoted 5 lines · Marek Behún
This module supports not not only Alaska X, but also Alaska M.
Change module description appropriately.
Signed-off-by Marek Behún <[email protected]>
Andrew
Andrew Lunn
maintainerRe: [PATCH net-next v3 04/18] net: phy: marvell10g: indicate 88X33x0 only port control registers
In reply to Marek Behúndrivers/net/phy/marvell10g.c static int mv3310_config_init(struct phy_device *phydev) · line 486
Quoted 12 lines
drivers/net/phy/marvell10g.c +2
-2@@ -479,8 +479,8 @@ static int mv3310_config_init(struct phy_device *phydev) val =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL );if (val <0 )return val; - priv->rate_match = ((val &MV_V2_PORT_CTRL_MACTYPE_MASK ) == -MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH ); + priv->rate_match = ((val &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ) == +MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH );/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );
So it appears that mv3310_config_init() should not be used with the mv88x2110. Did i miss somewhere where mv3310_drivers was changed so it actually does not use it?
Andrew
Marek Behún
maintainerRe: [PATCH net-next v3 04/18] net: phy: marvell10g: indicate 88X33x0 only port control registers
Quoted 17 lines · On Wed, 7 Apr 2021 02:10:24 +0200 Andrew Lunn <[email protected]> wrote:
drivers/net/phy/marvell10g.c static int mv3310_config_init(struct phy_device *phydev) · line 486
Quoted 12 lines
drivers/net/phy/marvell10g.c +2
-2@@ -479,8 +479,8 @@ static int mv3310_config_init(struct phy_device *phydev) val =phy_read_mmd (phydev,MDIO_MMD_VEND2 ,MV_V2_PORT_CTRL );if (val <0 )return val; - priv->rate_match = ((val &MV_V2_PORT_CTRL_MACTYPE_MASK ) == -MV_V2_PORT_CTRL_MACTYPE_RATE_MATCH ); + priv->rate_match = ((val &MV_V2_33X0_PORT_CTRL_MACTYPE_MASK ) == +MV_V2_33X0_PORT_CTRL_MACTYPE_RATE_MATCH );/* Enable EDPD mode - saving 600mW */ return mv3310_set_edpd (phydev,ETHTOOL_PHY_EDPD_DFLT_TX_MSECS );So it appears that
mv3310_config_init()should not be used with the mv88x2110. Did i miss somewhere wheremv3310_driverswas changed so it actually does not use it?
Quoted 1 line
Andrew
This patch series makes it later so that mv3310_config_init() correctly initializes even 2210 (this is done in patch 07/18). The function then calls chip->get_mactype() and chip->init_interface() methods, which are different for 3310 than for 2110.
I am thinking about whether all the functions which are same for all the chips should be renamed from
mv3310_*
to
mv10g_*
This would rename
mv3310_config_init
to
mv10g_config_init
which would be more correct.
What do you think?
Marek
kernel test robot
build botRe: [PATCH net-next v3 10/18] net: phy: marvell10g: check for correct supported interface mode
In reply to Marek BehúnThank you for the patch! Perhaps something to improve:
Hi "Marek,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Marek-Beh-n/net-phy-marvell10g-updates/20210407-061341 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git cc0626c2aaed8e475efdd85fa374b497a7192e35 config: nds32-randconfig-r034-20210407 (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d4164bb365f009cf1dc0180bb93a8fd1ca175982
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Marek-Beh-n/net-phy-marvell10g-updates/20210407-061341 git checkout d4164bb365f009cf1dc0180bb93a8fd1ca175982
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/spinlock.h:59,
from include/linux/phy.h:15,
from drivers/net/phy/marvell10g.c:29:
>> include/linux/bitmap.h:133:3: warning: initialized field overwritten [-Woverride-init]
133 | (0 EXPAND_FOR_EACH(_INIT_BITMAP_MEMBER_VALUE, \
| ^
include/linux/variadic-macro.h:100:24: note: in definition of macro '_VM_EVAL3'
100 | #define _VM_EVAL3(...) __VA_ARGS__
| ^~~~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:97:26: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:97:36: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
--
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:97:36: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:102:44: note: in expansion of macro '_INIT_BITMAP_MEMBER'
102 | #define _VM_APPLY(x, _functor, _data, ...) _functor(x, _data, ##__VA_ARGS__)
| ^~~~~~~~
include/linux/variadic-macro.h:103:30: note: in expansion of macro '_VM_APPLY'
103 | #define _VM_APPLY_INDIRECT() _VM_APPLY
| ^~~~~~~~~
include/linux/variadic-macro.h:97:46: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:105:37: note: in expansion of macro '_VM_DEFER'
105 | _VM_DEFER(_VM_APPLY_INDIRECT)()(x, _VM_DEFER __args)
| ^~~~~~~~~
include/linux/variadic-macro.h:26:36: note: in expansion of macro '_VM_APPLY_HELPER'
26 | #define _VM_HELP_6(_f, _d, x, ...) _f(x, _d) _VM_HELP_5(_f, _d, ##__VA_ARGS__)
| ^~
include/linux/variadic-macro.h:27:46: note: in expansion of macro '_VM_HELP_6'
27 | #define _VM_HELP_7(_f, _d, x, ...) _f(x, _d) _VM_HELP_6(_f, _d, ##__VA_ARGS__)
| ^~~~~~~~~~
include/linux/variadic-macro.h:18:40: note: in expansion of macro '_VM_HELP_7'
18 | _27, _28, _29, _30, _31, _32, N, ...) N
| ^
include/linux/variadic-macro.h:107:40: note: in expansion of macro 'EXPAND_FOR_EACH'
107 | #define _VM_EXPAND_FOR_EACH_INDIRECT() EXPAND_FOR_EACH
| ^~~~~~~~~~~~~~~
include/linux/variadic-macro.h:183:2: note: in expansion of macro 'EXPAND_EVAL'
183 | EXPAND_EVAL(_VM_EXPAND_FOR_EACH_PASS_ARGS(_functor, \
| ^~~~~~~~~~~
include/linux/variadic-macro.h:183:14: note: in expansion of macro '_VM_EXPAND_FOR_EACH_PASS_ARGS'
183 | EXPAND_EVAL(_VM_EXPAND_FOR_EACH_PASS_ARGS(_functor, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitmap.h:137:3: note: in expansion of macro 'EXPAND_FOR_EACH_PASS_ARGS'
137 | EXPAND_FOR_EACH_PASS_ARGS(_INIT_BITMAP_MEMBER, (nbits), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/phy/marvell10g.c:858:3: note: in expansion of macro 'INITIALIZE_BITMAP'
858 | INITIALIZE_BITMAP(PHY_INTERFACE_MODE_MAX,
| ^~~~~~~~~~~~~~~~~
>> include/linux/bitmap.h:133:3: warning: initialized field overwritten [-Woverride-init]
133 | (0 EXPAND_FOR_EACH(_INIT_BITMAP_MEMBER_VALUE, \
| ^
include/linux/variadic-macro.h:100:24: note: in definition of macro '_VM_EVAL3'
100 | #define _VM_EVAL3(...) __VA_ARGS__
| ^~~~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:97:26: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:34: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:44: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:97:36: note: in expansion of macro '_VM_EVAL1'
97 | #define EXPAND_EVAL(...) _VM_EVAL1(_VM_EVAL1(_VM_EVAL1(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:98:24: note: in expansion of macro '_VM_EVAL2'
98 | #define _VM_EVAL1(...) _VM_EVAL2(_VM_EVAL2(_VM_EVAL2(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:24: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:34: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))
| ^~~~~~~~~
include/linux/variadic-macro.h:99:44: note: in expansion of macro '_VM_EVAL3'
99 | #define _VM_EVAL2(...) _VM_EVAL3(_VM_EVAL3(_VM_EVAL3(__VA_ARGS__)))..
vim +133 include/linux/bitmap.h
^1da177e4c3f41 Linus Torvalds 2005-04-16 6
^1da177e4c3f41 Linus Torvalds 2005-04-16 7 #include <linux/types.h>
^1da177e4c3f41 Linus Torvalds 2005-04-16 8 #include <linux/bitops.h>
^1da177e4c3f41 Linus Torvalds 2005-04-16 9 #include <linux/string.h>
14ed9d23aa9acd Jiri Slaby 2007-10-18 10 #include <linux/kernel.h>
cf41ad5b8211f9 Marek Behún 2021-04-07 @11 #include <linux/variadic-macro.h>
^1da177e4c3f41 Linus Torvalds 2005-04-16 12
^1da177e4c3f41 Linus Torvalds 2005-04-16 13 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 14 * bitmaps provide bit arrays that consume one or more unsigned
^1da177e4c3f41 Linus Torvalds 2005-04-16 15 * longs. The bitmap interface and available operations are listed
^1da177e4c3f41 Linus Torvalds 2005-04-16 16 * here, in bitmap.h
^1da177e4c3f41 Linus Torvalds 2005-04-16 17 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 18 * Function implementations generic to all architectures are in
^1da177e4c3f41 Linus Torvalds 2005-04-16 19 * lib/bitmap.c. Functions implementations that are architecture
^1da177e4c3f41 Linus Torvalds 2005-04-16 20 * specific are in various include/asm-<arch>/bitops.h headers
^1da177e4c3f41 Linus Torvalds 2005-04-16 21 * and other arch/<arch> specific files.
^1da177e4c3f41 Linus Torvalds 2005-04-16 22 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 23 * See lib/bitmap.c for more details.
^1da177e4c3f41 Linus Torvalds 2005-04-16 24 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 25
7d7363e403ce95 Randy Dunlap 2017-10-16 26 /**
7d7363e403ce95 Randy Dunlap 2017-10-16 27 * DOC: bitmap overview
7d7363e403ce95 Randy Dunlap 2017-10-16 28 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 29 * The available bitmap operations and their rough meaning in the
^1da177e4c3f41 Linus Torvalds 2005-04-16 30 * case that the bitmap is a single unsigned long are thus:
^1da177e4c3f41 Linus Torvalds 2005-04-16 31 *
41e7b1661ffbf5 Rasmus Villemoes 2018-10-30 32 * The generated code is more efficient when nbits is known at
41e7b1661ffbf5 Rasmus Villemoes 2018-10-30 33 * compile-time and at most BITS_PER_LONG.
08cd36570e4717 Andi Kleen 2006-06-26 34 *
7d7363e403ce95 Randy Dunlap 2017-10-16 35 * ::
7d7363e403ce95 Randy Dunlap 2017-10-16 36 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 37 * bitmap_zero(dst, nbits) *dst = 0UL
^1da177e4c3f41 Linus Torvalds 2005-04-16 38 * bitmap_fill(dst, nbits) *dst = ~0UL
^1da177e4c3f41 Linus Torvalds 2005-04-16 39 * bitmap_copy(dst, src, nbits) *dst = *src
^1da177e4c3f41 Linus Torvalds 2005-04-16 40 * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2
^1da177e4c3f41 Linus Torvalds 2005-04-16 41 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2
^1da177e4c3f41 Linus Torvalds 2005-04-16 42 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2
^1da177e4c3f41 Linus Torvalds 2005-04-16 43 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
^1da177e4c3f41 Linus Torvalds 2005-04-16 44 * bitmap_complement(dst, src, nbits) *dst = ~(*src)
^1da177e4c3f41 Linus Torvalds 2005-04-16 45 * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal?
^1da177e4c3f41 Linus Torvalds 2005-04-16 46 * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap?
^1da177e4c3f41 Linus Torvalds 2005-04-16 47 * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2?
^1da177e4c3f41 Linus Torvalds 2005-04-16 48 * bitmap_empty(src, nbits) Are all bits zero in *src?
^1da177e4c3f41 Linus Torvalds 2005-04-16 49 * bitmap_full(src, nbits) Are all bits set in *src?
^1da177e4c3f41 Linus Torvalds 2005-04-16 50 * bitmap_weight(src, nbits) Hamming Weight: number set bits
c1a2a962a2ad10 Akinobu Mita 2009-12-15 51 * bitmap_set(dst, pos, nbits) Set specified bit area
c1a2a962a2ad10 Akinobu Mita 2009-12-15 52 * bitmap_clear(dst, pos, nbits) Clear specified bit area
c1a2a962a2ad10 Akinobu Mita 2009-12-15 53 * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area
780d2a9c86dc12 Wolfram Sang 2020-03-04 54 * bitmap_find_next_zero_area_off(buf, len, pos, n, mask, mask_off) as above
a392d26f32cdd8 Wolfram Sang 2020-03-04 55 * bitmap_next_clear_region(map, &start, &end, nbits) Find next clear region
a392d26f32cdd8 Wolfram Sang 2020-03-04 56 * bitmap_next_set_region(map, &start, &end, nbits) Find next set region
a392d26f32cdd8 Wolfram Sang 2020-03-04 57 * bitmap_for_each_clear_region(map, rs, re, start, end)
a392d26f32cdd8 Wolfram Sang 2020-03-04 58 * Iterate over all clear regions
a392d26f32cdd8 Wolfram Sang 2020-03-04 59 * bitmap_for_each_set_region(map, rs, re, start, end)
a392d26f32cdd8 Wolfram Sang 2020-03-04 60 * Iterate over all set regions
^1da177e4c3f41 Linus Torvalds 2005-04-16 61 * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
^1da177e4c3f41 Linus Torvalds 2005-04-16 62 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
2092767168f068 Stefano Brivio 2020-01-22 63 * bitmap_cut(dst, src, first, n, nbits) Cut n bits from first, copy rest
30544ed5de431f Andy Shevchenko 2019-12-04 64 * bitmap_replace(dst, old, new, mask, nbits) *dst = (*old & ~(*mask)) | (*new & *mask)
fb5eeeee44edb2 Paul Jackson 2005-10-30 65 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
fb5eeeee44edb2 Paul Jackson 2005-10-30 66 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
7ea931c9fc80c4 Paul Jackson 2008-04-28 67 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
7ea931c9fc80c4 Paul Jackson 2008-04-28 68 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
01a3ee2b203e51 Reinette Chatre 2006-10-11 69 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
01a3ee2b203e51 Reinette Chatre 2006-10-11 70 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
4b060420a59609 Mike Travis 2011-05-24 71 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
4b060420a59609 Mike Travis 2011-05-24 72 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
87e24802586333 Paul Jackson 2006-03-24 73 * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
87e24802586333 Paul Jackson 2006-03-24 74 * bitmap_release_region(bitmap, pos, order) Free specified bit region
87e24802586333 Paul Jackson 2006-03-24 75 * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
c724f193619c89 Yury Norov 2018-02-06 76 * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst
c724f193619c89 Yury Norov 2018-02-06 77 * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst
169c474fb22d8a William Breathitt Gray 2019-12-04 78 * bitmap_get_value8(map, start) Get 8bit value from map at start
169c474fb22d8a William Breathitt Gray 2019-12-04 79 * bitmap_set_value8(map, value, start) Set 8bit value to map@start
7d7363e403ce95 Randy Dunlap 2017-10-16 80 *
334cfa48d38f54 Andy Shevchenko 2018-02-06 81 * Note, bitmap_zero() and bitmap_fill() operate over the region of
334cfa48d38f54 Andy Shevchenko 2018-02-06 82 * unsigned longs, that is, bits behind bitmap till the unsigned long
334cfa48d38f54 Andy Shevchenko 2018-02-06 83 * boundary will be zeroed or filled as well. Consider to use
334cfa48d38f54 Andy Shevchenko 2018-02-06 84 * bitmap_clear() or bitmap_set() to make explicit zeroing or filling
334cfa48d38f54 Andy Shevchenko 2018-02-06 85 * respectively.
^1da177e4c3f41 Linus Torvalds 2005-04-16 86 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 87
7d7363e403ce95 Randy Dunlap 2017-10-16 88 /**
7d7363e403ce95 Randy Dunlap 2017-10-16 89 * DOC: bitmap bitops
7d7363e403ce95 Randy Dunlap 2017-10-16 90 *
7d7363e403ce95 Randy Dunlap 2017-10-16 91 * Also the following operations in asm/bitops.h apply to bitmaps.::
^1da177e4c3f41 Linus Torvalds 2005-04-16 92 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 93 * set_bit(bit, addr) *addr |= bit
^1da177e4c3f41 Linus Torvalds 2005-04-16 94 * clear_bit(bit, addr) *addr &= ~bit
^1da177e4c3f41 Linus Torvalds 2005-04-16 95 * change_bit(bit, addr) *addr ^= bit
^1da177e4c3f41 Linus Torvalds 2005-04-16 96 * test_bit(bit, addr) Is bit set in *addr?
^1da177e4c3f41 Linus Torvalds 2005-04-16 97 * test_and_set_bit(bit, addr) Set bit and return old value
^1da177e4c3f41 Linus Torvalds 2005-04-16 98 * test_and_clear_bit(bit, addr) Clear bit and return old value
^1da177e4c3f41 Linus Torvalds 2005-04-16 99 * test_and_change_bit(bit, addr) Change bit and return old value
^1da177e4c3f41 Linus Torvalds 2005-04-16 100 * find_first_zero_bit(addr, nbits) Position first zero bit in *addr
^1da177e4c3f41 Linus Torvalds 2005-04-16 101 * find_first_bit(addr, nbits) Position first set bit in *addr
0ade34c37012ea Clement Courbet 2018-02-06 102 * find_next_zero_bit(addr, nbits, bit)
0ade34c37012ea Clement Courbet 2018-02-06 103 * Position next zero bit in *addr >= bit
^1da177e4c3f41 Linus Torvalds 2005-04-16 104 * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
0ade34c37012ea Clement Courbet 2018-02-06 105 * find_next_and_bit(addr1, addr2, nbits, bit)
0ade34c37012ea Clement Courbet 2018-02-06 106 * Same as find_next_bit, but in
0ade34c37012ea Clement Courbet 2018-02-06 107 * (*addr1 & *addr2)
7d7363e403ce95 Randy Dunlap 2017-10-16 108 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 109 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 110
7d7363e403ce95 Randy Dunlap 2017-10-16 111 /**
7d7363e403ce95 Randy Dunlap 2017-10-16 112 * DOC: declare bitmap
^1da177e4c3f41 Linus Torvalds 2005-04-16 113 * The DECLARE_BITMAP(name,bits) macro, in linux/types.h, can be used
^1da177e4c3f41 Linus Torvalds 2005-04-16 114 * to declare an array named 'name' of just enough unsigned longs to
^1da177e4c3f41 Linus Torvalds 2005-04-16 115 * contain all bit positions from 0 to 'bits' - 1.
^1da177e4c3f41 Linus Torvalds 2005-04-16 116 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 117
cf41ad5b8211f9 Marek Behún 2021-04-07 118 /**
cf41ad5b8211f9 Marek Behún 2021-04-07 119 * DOC: initialize bitmap
cf41ad5b8211f9 Marek Behún 2021-04-07 120 * The INITIALIZE_BITMAP(bits, args...) macro expands to a designated
cf41ad5b8211f9 Marek Behún 2021-04-07 121 * initializer for bitmap of length 'bits', setting each bit specified
cf41ad5b8211f9 Marek Behún 2021-04-07 122 * in 'args...'.
cf41ad5b8211f9 Marek Behún 2021-04-07 123 */
cf41ad5b8211f9 Marek Behún 2021-04-07 124 #define _BIT_MEMBER(bit) ((bit) / BITS_PER_LONG)
cf41ad5b8211f9 Marek Behún 2021-04-07 125 #define _VERIFY_BIT(bit, nbits) \
cf41ad5b8211f9 Marek Behún 2021-04-07 126 BUILD_BUG_ON_ZERO((bit) < 0 || (bit) >= (nbits))
cf41ad5b8211f9 Marek Behún 2021-04-07 127 #define _INIT_BITMAP_MEMBER_VALUE(bit, member_bit) \
cf41ad5b8211f9 Marek Behún 2021-04-07 128 | (_BIT_MEMBER(bit) == _BIT_MEMBER(member_bit) \
cf41ad5b8211f9 Marek Behún 2021-04-07 129 ? BIT((bit) % BITS_PER_LONG) \
cf41ad5b8211f9 Marek Behún 2021-04-07 130 : 0)
cf41ad5b8211f9 Marek Behún 2021-04-07 131 #define _INIT_BITMAP_MEMBER(bit, nbits, ...) \
cf41ad5b8211f9 Marek Behún 2021-04-07 132 [_VERIFY_BIT((bit), (nbits)) + _BIT_MEMBER(bit)] = \
cf41ad5b8211f9 Marek Behún 2021-04-07 @133 (0 EXPAND_FOR_EACH(_INIT_BITMAP_MEMBER_VALUE, \
cf41ad5b8211f9 Marek Behún 2021-04-07 134 (bit), ##__VA_ARGS__)),
cf41ad5b8211f9 Marek Behún 2021-04-07 135 #define INITIALIZE_BITMAP(nbits, ...) \
cf41ad5b8211f9 Marek Behún 2021-04-07 136 { \
cf41ad5b8211f9 Marek Behún 2021-04-07 137 EXPAND_FOR_EACH_PASS_ARGS(_INIT_BITMAP_MEMBER, (nbits), \
cf41ad5b8211f9 Marek Behún 2021-04-07 138 ##__VA_ARGS__) \
cf41ad5b8211f9 Marek Behún 2021-04-07 139 }
cf41ad5b8211f9 Marek Behún 2021-04-07 140 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org