net: pcs: xpcs: cleanups batch 2
Subsystems (8)
Russell King (Oracle)
reviewercover net: pcs: xpcs: cleanups batch 2
This is the second cleanup series for XPCS.
Patch 1 removes the enum indexing the dw_xpcs_compat array. The index is never used except to place entries in the array and to size the array.
Patch 2 removes the interface arrays - each of which only contain one interface.
Patch 3 makes xpcs_find_compat() take the xpcs structure rather than the ID - the previous series removed the reason for xpcs_find_compat needing to take the ID.
Patch 4 provides a helper to convert xpcs structure to a regular phylink_pcs structure, which leads to patch 5.
Patch 5 moves the definition of struct dw_xpcs to the private xpcs header - with patch 4 in place, nothing outside of the xpcs driver accesses the contents of the dw_xpcs structure.
Patch 6 renames xpcs_get_id() to xpcs_read_id() since it's reading the ID, rather than doing anything further with it. (Prior versions of this series renamed it to xpcs_read_phys_id() since that more accurately described that it was reading the physical ID registers.)
Patch 7 moves the searching of the ID list out of line as this is a separate functional block.
Patch 8 converts xpcs to use the bitmap macros, which eliminates the need for _SHIFT definitions.
Patch 9 adds and uses _modify() accessors as there are a large amount of read-modify-write operations in this driver. This conversion found a bug in xpcs-wx code that has been reported and already fixed.
Patch 10 converts xpcs to use read_poll_timeout() rather than open coding that.
Patch 11 converts all printed messages to use the dev_*() functions so the driver and devie name are always printed.
Patch 12 moves DW_VR_MII_DIG_CTRL1_2G5_EN to the correct place in the header file, rather than amongst another register's definitions.
Patch 13 moves the Wangxun workaround to a common location rather than duplicating it in two places. We also reformat this to fit within 80 columns.
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/pcs/pcs-xpcs-nxp.c | 24 +- drivers/net/pcs/pcs-xpcs-wx.c | 56 ++- drivers/net/pcs/pcs-xpcs.c | 445 +++++++++------------- drivers/net/pcs/pcs-xpcs.h | 26 +- include/linux/pcs/pcs-xpcs.h | 19 +- 6 files changed, 237 insertions(+), 335 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/13 net: pcs: xpcs: remove dw_xpcs_compat enum
There is no reason for the struct dw_xpcs_compat arrays to be a fixed size other than the way we iterate over them. The index into the array isn't used for anything, and having them fixed size needlessly wastes space.
Remove the enum that defines their size, and instead use an empty array entry (with NULL ->supported) to mark the end of the array.
--- drivers/net/pcs/pcs-xpcs.c | 69 ++++++++++++++------------------------ 1 file changed, 25 insertions(+), 44 deletions(-)
drivers/net/pcs/pcs-xpcs.c +25 -44
@@ -135,17 +135,6 @@ static const phy_interface_t xpcs_2500basex_interfaces[] = { PHY_INTERFACE_MODE_2500BASEX, }; -enum { -DW_XPCS_USXGMII , -DW_XPCS_10GKR , -DW_XPCS_XLGMII , -DW_XPCS_10GBASER , -DW_XPCS_SGMII , -DW_XPCS_1000BASEX , -DW_XPCS_2500BASEX , -DW_XPCS_INTERFACE_MAX , -}; -struct dw_xpcs_compat {const int *supported;const phy_interface_t *interface;
@@ -163,15 +152,13 @@ struct dw_xpcs_desc {static const struct dw_xpcs_compat *xpcs_find_compat (const struct dw_xpcs_desc *desc,phy_interface_t interface) { -int i, j; - -for (i =0 ; i <DW_XPCS_INTERFACE_MAX ; i++) { -const struct dw_xpcs_compat *compat = &desc->compat[i]; +const struct dw_xpcs_compat *compat; +int j; +for (compat = desc->compat; compat->supported; compat++)for (j =0 ; j < compat->num_interfaces; j++)if (compat->interface[j] == interface)return compat; - }return NULL ; }
@@ -610,14 +597,12 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported,void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces) { -int i, j; - -for (i =0 ; i <DW_XPCS_INTERFACE_MAX ; i++) { -const struct dw_xpcs_compat *compat = &xpcs->desc->compat[i]; +const struct dw_xpcs_compat *compat; +int j; +for (compat = xpcs->desc->compat; compat->supported; compat++)for (j =0 ; j < compat->num_interfaces; j++)__set_bit (compat->interface[j], interfaces); - } }EXPORT_SYMBOL_GPL (xpcs_get_interfaces);
@@ -1298,76 +1283,72 @@ static int xpcs_get_id(struct dw_xpcs *xpcs)return 0 ; } -static const struct dw_xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX ] = { - [DW_XPCS_USXGMII ] = { +static const struct dw_xpcs_compat synopsys_xpcs_compat[] = { + { .supported = xpcs_usxgmii_features, .interface = xpcs_usxgmii_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_usxgmii_interfaces), .an_mode =DW_AN_C73 , - }, - [DW_XPCS_10GKR ] = { + }, { .supported = xpcs_10gkr_features, .interface = xpcs_10gkr_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_10gkr_interfaces), .an_mode =DW_AN_C73 , - }, - [DW_XPCS_XLGMII ] = { + }, { .supported = xpcs_xlgmii_features, .interface = xpcs_xlgmii_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_xlgmii_interfaces), .an_mode =DW_AN_C73 , - }, - [DW_XPCS_10GBASER ] = { + }, { .supported = xpcs_10gbaser_features, .interface = xpcs_10gbaser_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_10gbaser_interfaces), .an_mode =DW_10GBASER , - }, - [DW_XPCS_SGMII ] = { + }, { .supported = xpcs_sgmii_features, .interface = xpcs_sgmii_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , - }, - [DW_XPCS_1000BASEX ] = { + }, { .supported = xpcs_1000basex_features, .interface = xpcs_1000basex_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_1000basex_interfaces), .an_mode =DW_AN_C37_1000BASEX , - }, - [DW_XPCS_2500BASEX ] = { + }, { .supported = xpcs_2500basex_features, .interface = xpcs_2500basex_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_2500basex_interfaces), .an_mode =DW_2500BASEX , - }, + }, { + } }; -static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[DW_XPCS_INTERFACE_MAX ] = { - [DW_XPCS_SGMII ] = { +static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[] = { + { .supported = xpcs_sgmii_features, .interface = xpcs_sgmii_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , .pma_config = nxp_sja1105_sgmii_pma_config, - }, + }, { + } }; -static const struct dw_xpcs_compat nxp_sja1110_xpcs_compat[DW_XPCS_INTERFACE_MAX ] = { - [DW_XPCS_SGMII ] = { +static const struct dw_xpcs_compat nxp_sja1110_xpcs_compat[] = { + { .supported = xpcs_sgmii_features, .interface = xpcs_sgmii_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , .pma_config = nxp_sja1110_sgmii_pma_config, - }, - [DW_XPCS_2500BASEX ] = { + }, { .supported = xpcs_2500basex_features, .interface = xpcs_2500basex_interfaces, .num_interfaces =ARRAY_SIZE (xpcs_2500basex_interfaces), .an_mode =DW_2500BASEX , .pma_config = nxp_sja1110_2500basex_pma_config, - }, + }, { + } };static const struct dw_xpcs_desc xpcs_desc_list[] = {
Signature · 1 line
2.30.2
PATCH 2/13 net: pcs: xpcs: don't use array for interface
In reply to Russell King (Oracle)Currently, xpcs uses an array of interfaces that each "compat" entry supports. When looking up the compat entry for an interface, we iterate over the compat entries and then over each interface.
Since each compat entry only has a single interface in its interfaces array, replace the array with a single member in the compat structure.
--- drivers/net/pcs/pcs-xpcs.c | 71 ++++++++------------------------------ 1 file changed, 14 insertions(+), 57 deletions(-)
drivers/net/pcs/pcs-xpcs.c +14 -57
@@ -107,38 +107,9 @@ static const int xpcs_2500basex_features[] = { __ETHTOOL_LINK_MODE_MASK_NBITS, }; -static const phy_interface_t xpcs_usxgmii_interfaces[] = { -PHY_INTERFACE_MODE_USXGMII , -}; - -static const phy_interface_t xpcs_10gkr_interfaces[] = { -PHY_INTERFACE_MODE_10GKR , -}; - -static const phy_interface_t xpcs_xlgmii_interfaces[] = { -PHY_INTERFACE_MODE_XLGMII , -}; - -static const phy_interface_t xpcs_10gbaser_interfaces[] = { -PHY_INTERFACE_MODE_10GBASER , -}; - -static const phy_interface_t xpcs_sgmii_interfaces[] = { -PHY_INTERFACE_MODE_SGMII , -}; - -static const phy_interface_t xpcs_1000basex_interfaces[] = { -PHY_INTERFACE_MODE_1000BASEX , -}; - -static const phy_interface_t xpcs_2500basex_interfaces[] = { -PHY_INTERFACE_MODE_2500BASEX , -}; -struct dw_xpcs_compat { +phy_interface_t interface;const int *supported; -const phy_interface_t *interface; -int num_interfaces;int an_mode;int (*pma_config)(struct dw_xpcs *xpcs); };
@@ -153,12 +124,10 @@ static const struct dw_xpcs_compat * xpcs_find_compat(const struct dw_xpcs_desc *desc, phy_interface_t interface) {const struct dw_xpcs_compat *compat; -int j;for (compat = desc->compat; compat->supported; compat++) -for (j =0 ; j < compat->num_interfaces; j++) -if (compat->interface[j] == interface) -return compat; +if (compat->interface == interface) +return compat;return NULL ; }
@@ -598,11 +567,9 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported,void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces) {const struct dw_xpcs_compat *compat; -int j;for (compat = xpcs->desc->compat; compat->supported; compat++) -for (j =0 ; j < compat->num_interfaces; j++) -__set_bit (compat->interface[j], interfaces); +__set_bit (compat->interface, interfaces); }EXPORT_SYMBOL_GPL (xpcs_get_interfaces);
@@ -1285,39 +1252,32 @@ static int xpcs_get_id(struct dw_xpcs *xpcs)static const struct dw_xpcs_compat synopsys_xpcs_compat[] = { { + .interface =PHY_INTERFACE_MODE_USXGMII , .supported = xpcs_usxgmii_features, - .interface = xpcs_usxgmii_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_usxgmii_interfaces), .an_mode =DW_AN_C73 , }, { + .interface =PHY_INTERFACE_MODE_10GKR , .supported = xpcs_10gkr_features, - .interface = xpcs_10gkr_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_10gkr_interfaces), .an_mode =DW_AN_C73 , }, { + .interface =PHY_INTERFACE_MODE_XLGMII , .supported = xpcs_xlgmii_features, - .interface = xpcs_xlgmii_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_xlgmii_interfaces), .an_mode =DW_AN_C73 , }, { + .interface =PHY_INTERFACE_MODE_10GBASER , .supported = xpcs_10gbaser_features, - .interface = xpcs_10gbaser_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_10gbaser_interfaces), .an_mode =DW_10GBASER , }, { + .interface =PHY_INTERFACE_MODE_SGMII , .supported = xpcs_sgmii_features, - .interface = xpcs_sgmii_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , }, { + .interface =PHY_INTERFACE_MODE_1000BASEX , .supported = xpcs_1000basex_features, - .interface = xpcs_1000basex_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_1000basex_interfaces), .an_mode =DW_AN_C37_1000BASEX , }, { + .interface =PHY_INTERFACE_MODE_2500BASEX , .supported = xpcs_2500basex_features, - .interface = xpcs_2500basex_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_2500basex_interfaces), .an_mode =DW_2500BASEX , }, { }
@@ -1325,9 +1285,8 @@ static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[] = { { + .interface =PHY_INTERFACE_MODE_SGMII , .supported = xpcs_sgmii_features, - .interface = xpcs_sgmii_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , .pma_config = nxp_sja1105_sgmii_pma_config, }, {
@@ -1336,15 +1295,13 @@ static const struct dw_xpcs_compat nxp_sja1105_xpcs_compat[] = {static const struct dw_xpcs_compat nxp_sja1110_xpcs_compat[] = { { + .interface =PHY_INTERFACE_MODE_SGMII , .supported = xpcs_sgmii_features, - .interface = xpcs_sgmii_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_sgmii_interfaces), .an_mode =DW_AN_C37_SGMII , .pma_config = nxp_sja1110_sgmii_pma_config, }, { + .interface =PHY_INTERFACE_MODE_2500BASEX , .supported = xpcs_2500basex_features, - .interface = xpcs_2500basex_interfaces, - .num_interfaces =ARRAY_SIZE (xpcs_2500basex_interfaces), .an_mode =DW_2500BASEX , .pma_config = nxp_sja1110_2500basex_pma_config, }, {
Signature · 1 line
2.30.2
PATCH 3/13 net: pcs: xpcs: pass xpcs instead of xpcs->id to xpcs_find_compat()
In reply to Russell King (Oracle)xpcs_find_compat() is now always passed xpcs->id. Rather than always dereferencing this in the caller, move it into xpcs_find_compat(), thus making this function consistent with most of the other xpcs functions in taking an xpcs pointer.
--- drivers/net/pcs/pcs-xpcs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/pcs/pcs-xpcs.c +7 -7
@@ -121,11 +121,11 @@ struct dw_xpcs_desc { };static const struct dw_xpcs_compat * -xpcs_find_compat (const struct dw_xpcs_desc *desc,phy_interface_t interface) +xpcs_find_compat (struct dw_xpcs *xpcs,phy_interface_t interface) {const struct dw_xpcs_compat *compat; -for (compat = desc->compat; compat->supported; compat++) +for (compat = xpcs->desc->compat; compat->supported; compat++)if (compat->interface == interface)return compat;
@@ -136,7 +136,7 @@ int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface) {const struct dw_xpcs_compat *compat; - compat =xpcs_find_compat (xpcs->desc, interface); + compat =xpcs_find_compat (xpcs, interface);if (!compat)return -ENODEV ;
@@ -548,7 +548,7 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported,int i; xpcs =phylink_pcs_to_xpcs (pcs); - compat =xpcs_find_compat (xpcs->desc, state->interface); + compat =xpcs_find_compat (xpcs, state->interface);if (!compat)return -EINVAL ;
@@ -620,7 +620,7 @@ static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface)if (!xpcs->need_reset)return ; - compat =xpcs_find_compat (xpcs->desc, interface); + compat =xpcs_find_compat (xpcs, interface);if (!compat) {dev_err (&xpcs->mdiodev->dev,"unsupported interface %s\n" ,phy_modes (interface));
@@ -810,7 +810,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,const struct dw_xpcs_compat *compat;int ret; - compat =xpcs_find_compat (xpcs->desc, interface); + compat =xpcs_find_compat (xpcs, interface);if (!compat)return -ENODEV ;
@@ -1074,7 +1074,7 @@ static void xpcs_get_state(struct phylink_pcs *pcs,const struct dw_xpcs_compat *compat;int ret; - compat =xpcs_find_compat (xpcs->desc, state->interface); + compat =xpcs_find_compat (xpcs, state->interface);if (!compat)return ;
Signature · 1 line
2.30.2
PATCH 4/13 net: pcs: xpcs: provide a helper to get the phylink pcs given xpcs
In reply to Russell King (Oracle)Provide a helper to provide the pointer to the phylink_pcs struct given a valid xpcs pointer. This will be necessary when we make struct dw_xpcs private to pcs-xpcs.c
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 6 ++++++ include/linux/pcs/pcs-xpcs.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +1 -1
@@ -451,7 +451,7 @@ static struct phylink_pcs *intel_mgbe_select_pcs(struct stmmac_priv *priv,* should always be an XPCS. The original code would always * return this if present. */ -return &priv->hw->xpcs->pcs; +return xpcs_to_phylink_pcs (priv->hw->xpcs); } static int intel_mgbe_common_data(struct pci_dev *pdev,
drivers/net/pcs/pcs-xpcs.c +6 -0
@@ -132,6 +132,12 @@ xpcs_find_compat(struct dw_xpcs *xpcs, phy_interface_t interface)return NULL ; } +struct phylink_pcs *xpcs_to_phylink_pcs (struct dw_xpcs *xpcs) +{ +return &xpcs->pcs; +} +EXPORT_SYMBOL_GPL (xpcs_to_phylink_pcs); +int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface) {const struct dw_xpcs_compat *compat;
include/linux/pcs/pcs-xpcs.h +1 -0
@@ -64,6 +64,7 @@ struct dw_xpcs {bool need_reset; }; +struct phylink_pcs *xpcs_to_phylink_pcs (struct dw_xpcs *xpcs);int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface);void xpcs_get_interfaces (struct dw_xpcs *xpcs,unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns,
Signature · 1 line
2.30.2
PATCH 5/13 net: pcs: xpcs: move definition of struct dw_xpcs to private header
In reply to Russell King (Oracle)There should be no reason for anything outside the XPCS code to know the contents of struct dw_xpcs - this is a private structure to XPCS. Move the definition to the private pcs-xpcs.h header, leaving a declaration in the global pcs/pcs-xpcs.h
--- drivers/net/pcs/pcs-xpcs.h | 18 ++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 18 +----------------- 2 files changed, 19 insertions(+), 17 deletions(-)
drivers/net/pcs/pcs-xpcs.h +18 -0
@@ -123,6 +123,24 @@#define DW_XPCS_INFO_DECLARE (_name, _pcs, _pma) \ static const struct dw_xpcs_info _name = { .pcs = _pcs, .pma = _pma } +struct dw_xpcs_desc ; + +enum dw_xpcs_clock { +DW_XPCS_CORE_CLK , +DW_XPCS_PAD_CLK , +DW_XPCS_NUM_CLKS , +}; + +struct dw_xpcs { +struct dw_xpcs_info info; +const struct dw_xpcs_desc *desc; +struct mdio_device *mdiodev; +struct clk_bulk_data clks[DW_XPCS_NUM_CLKS ]; +struct phylink_pcs pcs; +phy_interface_t interface; +bool need_reset; +}; +int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg);int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val);int xpcs_read_vpcs (struct dw_xpcs *xpcs,int reg);
include/linux/pcs/pcs-xpcs.h +1 -17
@@ -21,8 +21,6 @@#define DW_AN_C37_1000BASEX 4#define DW_10GBASER 5 -struct dw_xpcs_desc ; -enum dw_xpcs_pcs_id {DW_XPCS_ID_NATIVE =0 ,NXP_SJA1105_XPCS_ID =0x00000010 ,
@@ -48,21 +46,7 @@ struct dw_xpcs_info {u32 pma; }; -enum dw_xpcs_clock { -DW_XPCS_CORE_CLK , -DW_XPCS_PAD_CLK , -DW_XPCS_NUM_CLKS , -}; - -struct dw_xpcs { -struct dw_xpcs_info info; -const struct dw_xpcs_desc *desc; -struct mdio_device *mdiodev; -struct clk_bulk_data clks[DW_XPCS_NUM_CLKS ]; -struct phylink_pcs pcs; -phy_interface_t interface; -bool need_reset; -}; +struct dw_xpcs ;struct phylink_pcs *xpcs_to_phylink_pcs (struct dw_xpcs *xpcs);int xpcs_get_an_mode (struct dw_xpcs *xpcs,phy_interface_t interface);
Signature · 1 line
2.30.2
PATCH 6/13 net: pcs: xpcs: rename xpcs_get_id()
In reply to Russell King (Oracle)Rename xpcs_get_id() to xpcs_read_id() which more closely reflects the purpose of this function.
--- drivers/net/pcs/pcs-xpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs.c +2 -2
@@ -1190,7 +1190,7 @@ static void xpcs_an_restart(struct phylink_pcs *pcs) } } -static int xpcs_get_id (struct dw_xpcs *xpcs) +static int xpcs_read_ids (struct dw_xpcs *xpcs) {int ret;u32 id;
@@ -1405,7 +1405,7 @@ static int xpcs_init_id(struct dw_xpcs *xpcs) xpcs->info = *info; } - ret =xpcs_get_id (xpcs); + ret =xpcs_read_ids (xpcs);if (ret <0 )return ret;
Signature · 1 line
2.30.2
PATCH 7/13 net: pcs: xpcs: move searching ID list out of line
In reply to Russell King (Oracle)Move the searching of the physical ID out of xpcs_create() and into its own xpcs_identify() function, which makes it self contained. This reduces the complexity in xpcs_craete(), making it easier to follow, rather than having a lot of once-run code in the big for() loop.
--- drivers/net/pcs/pcs-xpcs.c | 41 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/net/pcs/pcs-xpcs.c +21 -20
@@ -1339,6 +1339,26 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; +static int xpcs_identify (struct dw_xpcs *xpcs) +{ +int i, ret; + + ret =xpcs_read_ids (xpcs); +if (ret <0 ) +return ret; + +for (i =0 ; i <ARRAY_SIZE (xpcs_desc_list); i++) { +const struct dw_xpcs_desc *entry = &xpcs_desc_list[i]; + +if ((xpcs->info.pcs & entry->mask) == entry->id) { + xpcs->desc = entry; +return 0 ; + } + } + +return -ENODEV ; +} +static struct dw_xpcs *xpcs_create_data (struct mdio_device *mdiodev) {struct dw_xpcs *xpcs;
@@ -1395,7 +1415,6 @@ static void xpcs_clear_clks(struct dw_xpcs *xpcs)static int xpcs_init_id (struct dw_xpcs *xpcs) {const struct dw_xpcs_info *info; -int i, ret; info =dev_get_platdata (&xpcs->mdiodev->dev);if (!info) {
@@ -1405,25 +1424,7 @@ static int xpcs_init_id(struct dw_xpcs *xpcs) xpcs->info = *info; } - ret =xpcs_read_ids (xpcs); -if (ret <0 ) -return ret; - -for (i =0 ; i <ARRAY_SIZE (xpcs_desc_list); i++) { -const struct dw_xpcs_desc *desc = &xpcs_desc_list[i]; - -if ((xpcs->info.pcs & desc->mask) != desc->id) -continue ; - - xpcs->desc = desc; - -break ; - } - -if (!xpcs->desc) -return -ENODEV ; - -return 0 ; +return xpcs_identify (xpcs); }static struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev)
Signature · 1 line
2.30.2
PATCH 8/13 net: pcs: xpcs: use FIELD_PREP() and FIELD_GET()
In reply to Russell King (Oracle)Convert xpcs to use the bitfield macros rather than definining the bitfield shifts and open-coding the insertion and extraction of these bitfields.
--- drivers/net/pcs/pcs-xpcs.c | 14 ++++++-------- drivers/net/pcs/pcs-xpcs.h | 4 ---- 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/pcs/pcs-xpcs.c +6 -8
@@ -592,7 +592,8 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) ret =DW_VR_MII_EEE_LTX_EN |DW_VR_MII_EEE_LRX_EN |DW_VR_MII_EEE_TX_QUIET_EN |DW_VR_MII_EEE_RX_QUIET_EN |DW_VR_MII_EEE_TX_EN_CTRL |DW_VR_MII_EEE_RX_EN_CTRL | - mult_fact_100ns <<DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT ; +FIELD_PREP (DW_VR_MII_EEE_MULT_FACT_100NS , + mult_fact_100ns); }else { ret &= ~(DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN |
@@ -681,9 +682,8 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,return ret; ret &= ~(DW_VR_MII_PCS_MODE_MASK |DW_VR_MII_TX_CONFIG_MASK ); - ret |= (DW_VR_MII_PCS_MODE_C37_SGMII << -DW_VR_MII_AN_CTRL_PCS_MODE_SHIFT & -DW_VR_MII_PCS_MODE_MASK ); + ret |=FIELD_PREP (DW_VR_MII_PCS_MODE_MASK , +DW_VR_MII_PCS_MODE_C37_SGMII );if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) { ret |=DW_VR_MII_AN_CTRL_8BIT ;/* Hardware requires it to be PHY side SGMII */
@@ -691,8 +691,7 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, }else { tx_conf =DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII ; } - ret |= tx_conf <<DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT & -DW_VR_MII_TX_CONFIG_MASK ; + ret |=FIELD_PREP (DW_VR_MII_TX_CONFIG_MASK , tx_conf); ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,DW_VR_MII_AN_CTRL , ret);if (ret <0 )return ret;
@@ -971,8 +970,7 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, state->link = true; - speed_value = (ret &DW_VR_MII_AN_STS_C37_ANSGM_SP ) >> -DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT ; + speed_value =FIELD_GET (DW_VR_MII_AN_STS_C37_ANSGM_SP , ret);if (speed_value ==DW_VR_MII_C37_ANSGM_SP_1000 ) state->speed =SPEED_1000 ;else if (speed_value ==DW_VR_MII_C37_ANSGM_SP_100 )
drivers/net/pcs/pcs-xpcs.h +0 -4
@@ -77,11 +77,9 @@/* VR_MII_AN_CTRL */ #define DW_VR_MII_AN_CTRL_8BIT BIT(8) -#define DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT 3#define DW_VR_MII_TX_CONFIG_MASK BIT(3)#define DW_VR_MII_TX_CONFIG_PHY_SIDE_SGMII 0x1#define DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII 0x0 -#define DW_VR_MII_AN_CTRL_PCS_MODE_SHIFT 1#define DW_VR_MII_PCS_MODE_MASK GENMASK(2, 1)#define DW_VR_MII_PCS_MODE_C37_1000BASEX 0x0#define DW_VR_MII_PCS_MODE_C37_SGMII 0x2
@@ -90,7 +88,6 @@/* VR_MII_AN_INTR_STS */ #define DW_VR_MII_AN_STS_C37_ANCMPLT_INTR BIT(0)#define DW_VR_MII_AN_STS_C37_ANSGM_FD BIT(1) -#define DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT 2#define DW_VR_MII_AN_STS_C37_ANSGM_SP GENMASK(3, 2)#define DW_VR_MII_C37_ANSGM_SP_10 0x0#define DW_VR_MII_C37_ANSGM_SP_100 0x1
@@ -114,7 +111,6 @@#define DW_VR_MII_EEE_TX_EN_CTRL BIT(4)/* Tx Control Enable */ #define DW_VR_MII_EEE_RX_EN_CTRL BIT(7)/* Rx Control Enable */ -#define DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT 8#define DW_VR_MII_EEE_MULT_FACT_100NS GENMASK(11, 8)/* VR MII EEE Control 1 defines */
Signature · 1 line
2.30.2
Paolo Abeni
maintainerRe: [PATCH net-next 08/13] net: pcs: xpcs: use FIELD_PREP() and FIELD_GET()
Hi,
Quoted 5 lines · Russell King (Oracle)
drivers/net/pcs/pcs-xpcs.c +0
-0
drivers/net/pcs/pcs-xpcs.c int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) · line 599
Quoted 9 lines
drivers/net/pcs/pcs-xpcs.c +2
-1@@ -592,7 +592,8 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) ret =DW_VR_MII_EEE_LTX_EN |DW_VR_MII_EEE_LRX_EN |DW_VR_MII_EEE_TX_QUIET_EN |DW_VR_MII_EEE_RX_QUIET_EN |DW_VR_MII_EEE_TX_EN_CTRL |DW_VR_MII_EEE_RX_EN_CTRL | - mult_fact_100ns <<DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT ; +FIELD_PREP (DW_VR_MII_EEE_MULT_FACT_100NS , + mult_fact_100ns); }else { ret &= ~(DW_VR_MII_EEE_LTX_EN | DW_VR_MII_EEE_LRX_EN | DW_VR_MII_EEE_TX_QUIET_EN | DW_VR_MII_EEE_RX_QUIET_EN |
Very minor and non blocking thing: perhaps consider renaming DW_VR_MII_EEE_MULT_FACT_100NS to DW_VR_MII_EEE_MULT_FACT_100NS_MASK - possibly in a later work?
Cheers,
Paolo
PATCH 9/13 net: pcs: xpcs: add _modify() accessors
In reply to Russell King (Oracle)The xpcs driver does a lot of read-modify-write operations on registers, which leads to long-winded code to read the register, check whether the read was successful, modify the value in some way, and then write it back.
We have a mdiodev _modify() accessor that encapsulates this, and does the register modification under the MDIO bus lock ensuring that the modification is atomic with respect to other bus operations. Convert the xpcs driver to use this accessor.
--- drivers/net/pcs/pcs-xpcs-nxp.c | 24 ++--- drivers/net/pcs/pcs-xpcs-wx.c | 56 +++++------ drivers/net/pcs/pcs-xpcs.c | 165 +++++++++++++++------------------ drivers/net/pcs/pcs-xpcs.h | 1 + 4 files changed, 104 insertions(+), 142 deletions(-)
drivers/net/pcs/pcs-xpcs-nxp.c +8 -16
@@ -152,26 +152,18 @@ static int nxp_sja1110_pma_config(struct dw_xpcs *xpcs,/* Enable TX and RX PLLs and circuits. * Release reset of PMA to enable data flow to/from PCS. */ - ret =xpcs_read (xpcs,MDIO_MMD_VEND2 ,SJA1110_POWERDOWN_ENABLE ); -if (ret <0 ) -return ret; - - val = ret & ~(SJA1110_TXPLL_PD |SJA1110_TXPD |SJA1110_RXCH_PD | -SJA1110_RXBIAS_PD |SJA1110_RESET_SER_EN | -SJA1110_RESET_SER |SJA1110_RESET_DES ); - val |=SJA1110_RXPKDETEN |SJA1110_RCVEN ; - - ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_POWERDOWN_ENABLE , val); + ret =xpcs_modify (xpcs,MDIO_MMD_VEND2 ,SJA1110_POWERDOWN_ENABLE , +SJA1110_TXPLL_PD |SJA1110_TXPD |SJA1110_RXCH_PD | +SJA1110_RXBIAS_PD |SJA1110_RESET_SER_EN | +SJA1110_RESET_SER |SJA1110_RESET_DES | +SJA1110_RXPKDETEN |SJA1110_RCVEN , +SJA1110_RXPKDETEN |SJA1110_RCVEN );if (ret <0 )return ret;/* Program continuous-time linear equalizer (CTLE) settings. */ - ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RX_CDR_CTLE , - rx_cdr_ctle); -if (ret <0 ) -return ret; - -return 0 ; +return xpcs_write (xpcs,MDIO_MMD_VEND2 ,SJA1110_RX_CDR_CTLE , + rx_cdr_ctle); }int nxp_sja1110_sgmii_pma_config (struct dw_xpcs *xpcs)
drivers/net/pcs/pcs-xpcs-wx.c +22 -34
101 lines not on this page · raw message
drivers/net/pcs/pcs-xpcs.c +73 -92
273 lines not on this page · raw message
drivers/net/pcs/pcs-xpcs.h +1 -0
@@ -139,6 +139,7 @@ struct dw_xpcs {int xpcs_read (struct dw_xpcs *xpcs,int dev,u32 reg);int xpcs_write (struct dw_xpcs *xpcs,int dev,u32 reg,u16 val); +int xpcs_modify (struct dw_xpcs *xpcs,int dev,u32 reg,u16 mask,u16 set);int xpcs_read_vpcs (struct dw_xpcs *xpcs,int reg);int xpcs_write_vpcs (struct dw_xpcs *xpcs,int reg,u16 val);int nxp_sja1105_sgmii_pma_config (struct dw_xpcs *xpcs);
Signature · 1 line
2.30.2
PATCH 10/13 net: pcs: xpcs: convert to use read_poll_timeout()
In reply to Russell King (Oracle)Convert the xpcs driver to use read_poll_timeout() when waiting for reset to complete, rather than open-coding this.
--- drivers/net/pcs/pcs-xpcs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/net/pcs/pcs-xpcs.c +7 -10
@@ -220,18 +220,15 @@ static int xpcs_modify_vpcs(struct dw_xpcs *xpcs, int reg, u16 mask, u16 val)static int xpcs_poll_reset (struct dw_xpcs *xpcs,int dev) { -/* Poll until the reset bit clears (50ms per retry == 0.6 sec) */ -unsigned int retries =12 ; -int ret; +int ret, val; -do { -msleep (50 ); - ret =xpcs_read (xpcs, dev,MDIO_CTRL1 ); -if (ret <0 ) -return ret; - }while (ret &MDIO_CTRL1_RESET && --retries); + ret =read_poll_timeout (xpcs_read, val, + val <0 || !(val &MDIO_CTRL1_RESET ), +50000 ,600000 , true, xpcs, dev,MDIO_CTRL1 ); +if (val <0 ) + ret = val; -return (ret &MDIO_CTRL1_RESET ) ? -ETIMEDOUT :0 ; +return ret; } static int xpcs_soft_reset(struct dw_xpcs *xpcs,
Signature · 1 line
2.30.2
PATCH 11/13 net: pcs: xpcs: use dev_*() to print messages
In reply to Russell King (Oracle)Use the dev_*() family of functions to print all messages from the XPCS driver so we know which instance issues the messages.
--- drivers/net/pcs/pcs-xpcs.c | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
drivers/net/pcs/pcs-xpcs.c +22 -22
@@ -356,7 +356,8 @@ static void xpcs_config_usxgmii(struct dw_xpcs *xpcs, int speed)return ; out: -pr_err ("%s: XPCS access returned %pe\n" , __func__,ERR_PTR (ret)); +dev_err (&xpcs->mdiodev->dev,"%s: XPCS access returned %pe\n" , + __func__,ERR_PTR (ret)); } static int _xpcs_config_aneg_c73(struct dw_xpcs *xpcs,
@@ -1070,32 +1071,27 @@ static void xpcs_get_state(struct phylink_pcs *pcs,break ;case DW_AN_C73 : ret =xpcs_get_state_c73 (xpcs, state, compat); -if (ret) { -pr_err ("xpcs_get_state_c73 returned %pe\n" , -ERR_PTR (ret)); -return ; - } +if (ret) +dev_err (&xpcs->mdiodev->dev,"%s returned %pe\n" , +"xpcs_get_state_c73" ,ERR_PTR (ret));break ;case DW_AN_C37_SGMII : ret =xpcs_get_state_c37_sgmii (xpcs, state); -if (ret) { -pr_err ("xpcs_get_state_c37_sgmii returned %pe\n" , -ERR_PTR (ret)); - } +if (ret) +dev_err (&xpcs->mdiodev->dev,"%s returned %pe\n" , +"xpcs_get_state_c37_sgmii" ,ERR_PTR (ret));break ;case DW_AN_C37_1000BASEX : ret =xpcs_get_state_c37_1000basex (xpcs, state); -if (ret) { -pr_err ("xpcs_get_state_c37_1000basex returned %pe\n" , -ERR_PTR (ret)); - } +if (ret) +dev_err (&xpcs->mdiodev->dev,"%s returned %pe\n" , +"xpcs_get_state_c37_1000basex" ,ERR_PTR (ret));break ;case DW_2500BASEX : ret =xpcs_get_state_2500basex (xpcs, state); -if (ret) { -pr_err ("xpcs_get_state_2500basex returned %pe\n" , -ERR_PTR (ret)); - } +if (ret) +dev_err (&xpcs->mdiodev->dev,"%s returned %pe\n" , +"xpcs_get_state_2500basex" ,ERR_PTR (ret));break ;default :return ;
@@ -1113,7 +1109,8 @@ static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int neg_mode, val =mii_bmcr_encode_fixed (speed, duplex); ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,MDIO_CTRL1 , val);if (ret) -pr_err ("%s: xpcs_write returned %pe\n" , __func__,ERR_PTR (ret)); +dev_err (&xpcs->mdiodev->dev,"%s: xpcs_write returned %pe\n" , + __func__,ERR_PTR (ret)); } static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, unsigned int neg_mode,
@@ -1131,18 +1128,21 @@ static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, unsigned int neg_mode,case SPEED_100 :case SPEED_10 :default : -pr_err ("%s: speed = %d\n" , __func__, speed); +dev_err (&xpcs->mdiodev->dev,"%s: speed = %d\n" , + __func__, speed);return ; }if (duplex ==DUPLEX_FULL ) val |=BMCR_FULLDPLX ;else -pr_err ("%s: half duplex not supported\n" , __func__); +dev_err (&xpcs->mdiodev->dev,"%s: half duplex not supported\n" , + __func__); ret =xpcs_write (xpcs,MDIO_MMD_VEND2 ,MDIO_CTRL1 , val);if (ret) -pr_err ("%s: xpcs_write returned %pe\n" , __func__,ERR_PTR (ret)); +dev_err (&xpcs->mdiodev->dev,"%s: xpcs_write returned %pe\n" , + __func__,ERR_PTR (ret)); } static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
Signature · 1 line
2.30.2
PATCH 12/13 net: pcs: xpcs: correctly place DW_VR_MII_DIG_CTRL1_2G5_EN
In reply to Russell King (Oracle)Place DW_VR_MII_DIG_CTRL1_2G5_EN with the other DW_VR_MII_DIG_CTRL1 definitions rather than in the middle of a register list.
--- drivers/net/pcs/pcs-xpcs.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs.h +1 -2
@@ -60,8 +60,6 @@#define DW_VR_MII_DIG_CTRL1 0x8000#define DW_VR_MII_AN_CTRL 0x8001#define DW_VR_MII_AN_INTR_STS 0x8002 -/* Enable 2.5G Mode */ -#define DW_VR_MII_DIG_CTRL1_2G5_EN BIT(2)/* EEE Mode Control Register */ #define DW_VR_MII_EEE_MCTRL0 0x8006#define DW_VR_MII_EEE_MCTRL1 0x800b
@@ -69,6 +67,7 @@/* VR_MII_DIG_CTRL1 */ #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9) +#define DW_VR_MII_DIG_CTRL1_2G5_EN BIT(2)#define DW_VR_MII_DIG_CTRL1_PHY_MODE_CTRL BIT(0)/* VR_MII_DIG_CTRL2 */
Signature · 1 line
2.30.2
PATCH 13/13 net: pcs: xpcs: move Wangxun VR_XS_PCS_DIG_CTRL1 configuration
In reply to Russell King (Oracle)According to commits 2a22b7ae2fa3 ("net: pcs: xpcs: adapt Wangxun NICs for SGMII mode") and 2deea43f386d ("net: pcs: xpcs: add 1000BASE-X AN interrupt support"), Wangxun devices need special VR_XS_PCS_DIG_CTRL1 settings for SGMII and 1000BASE-X. Both SGMII and 1000BASE-X use the same settings.
Rather than placing these in the individual xpcs_config_*() functions, move it to where we already test for the Wangxun devices in xpcs_do_config().
--- drivers/net/pcs/pcs-xpcs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/pcs/pcs-xpcs.c +8 -6
@@ -636,9 +636,6 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,int ret, mdio_ctrl, tx_conf;u16 mask, val; -if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) -xpcs_write_vpcs (xpcs,DW_VR_XS_PCS_DIG_CTRL1 ,DW_CL37_BP |DW_EN_VSMMD1 ); -/* For AN for C37 SGMII mode, the settings are :- * 1) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 0b (Disable SGMII AN in case it is already enabled)
@@ -714,9 +711,6 @@ static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs,bool changed =0 ;u16 mask, val; -if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) -xpcs_write_vpcs (xpcs,DW_VR_XS_PCS_DIG_CTRL1 ,DW_CL37_BP |DW_EN_VSMMD1 ); -/* According to Chap 7.12, to set 1000BASE-X C37 AN, AN must * be disabled first:- * 1) VR_MII_MMD_CTRL Bit(12)[AN_ENABLE] = 0b
@@ -806,6 +800,14 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, ret =txgbe_xpcs_switch_mode (xpcs, interface);if (ret)return ret; + +/* Wangxun devices need backplane CL37 AN enabled for +* SGMII and 1000base-X +*/ +if (interface ==PHY_INTERFACE_MODE_SGMII || + interface ==PHY_INTERFACE_MODE_1000BASEX ) +xpcs_write_vpcs (xpcs,DW_VR_XS_PCS_DIG_CTRL1 , +DW_CL37_BP |DW_EN_VSMMD1 ); }switch (compat->an_mode) {
Signature · 1 line
2.30.2
Russell King (Oracle)
reviewerQuoted 1 line · Russell King (Oracle)
This is the second cleanup series for XPCS.
As an additional note for Vladimir, the outstanding patches now are:
net: pcs: xpcs: convert to use linkmode_adv_to_c73()
net: pcs: xpcs: add xpcs_linkmode_supported()
net: mdio: add linkmode_adv_to_c73()
which based on your recent comment about c73 stuff, I'm not intending to submit due to the 2500base-[K]X issue. The second patch may be of some use however. I'll send that separately once this series has been reviewed.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Vladimir Oltean
maintainerQuoted 1 line · Russell King (Oracle)
drivers/net/pcs/pcs-xpcs-nxp.c | 24 +-
I want to test this on the SJA1110, but every XPCS cleanup series day is a new unpacking day. I have to take the board out of a box and make sure it still works. It might take a while.
Russell King (Oracle)
reviewerQuoted 6 lines · Vladimir Oltean
Quoted 1 line · Russell King (Oracle)
drivers/net/pcs/pcs-xpcs-nxp.c | 24 +-I want to test this on the SJA1110, but every XPCS cleanup series day is a new unpacking day. I have to take the board out of a box and make sure it still works. It might take a while.
Sorry about that - if netdev didn't have the "15 patches max" then I would've posted it as one series which would've saved you the additional work.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Hi
Quoted 40 lines · Russell King (Oracle)
This is the second cleanup series for XPCS.
Patch 1 removes the enum indexing the
dw_xpcs_compatarray. The index is never used except to place entries in the array and to size the array.Patch 2 removes the interface arrays - each of which only contain one interface.
Patch 3 makes
xpcs_find_compat()take the xpcs structure rather than the ID - the previous series removed the reason forxpcs_find_compatneeding to take the ID.Patch 4 provides a helper to convert xpcs structure to a regular
phylink_pcsstructure, which leads to patch 5.Patch 5 moves the definition of struct
dw_xpcsto the private xpcs header - with patch 4 in place, nothing outside of the xpcs driver accesses the contents of thedw_xpcsstructure.Patch 6 renames
xpcs_get_id()toxpcs_read_id()since it's reading the ID, rather than doing anything further with it. (Prior versions of this series renamed it toxpcs_read_phys_id()since that more accurately described that it was reading the physical ID registers.)Patch 7 moves the searching of the ID list out of line as this is a separate functional block.
Patch 8 converts xpcs to use the bitmap macros, which eliminates the need for
_SHIFTdefinitions.Patch 9 adds and uses
_modify()accessors as there are a large amount of read-modify-write operations in this driver. This conversion found a bug in xpcs-wx code that has been reported and already fixed.Patch 10 converts xpcs to use
read_poll_timeout()rather than open coding that.Patch 11 converts all printed messages to use the dev_*() functions so the driver and devie name are always printed.
Quoted 6 lines
Patch 12 moves
DW_VR_MII_DIG_CTRL1_2G5_ENto the correct place in the header file, rather than amongst another register's definitions.Patch 13 moves the Wangxun workaround to a common location rather than duplicating it in two places. We also reformat this to fit within 80 columns.
If you don't mind I'll test the series out on Monday or Tuesday on the next week after my local-tree changes concerning the DW XPCS driver are rebased onto it.
-Serge(y)
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/pcs/pcs-xpcs-nxp.c | 24 +- drivers/net/pcs/pcs-xpcs-wx.c | 56 ++- drivers/net/pcs/pcs-xpcs.c | 445 +++++++++------------- drivers/net/pcs/pcs-xpcs.h | 26 +- include/linux/pcs/pcs-xpcs.h | 19 +- 6 files changed, 237 insertions(+), 335 deletions(-)Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Serge Semin
Tested-byQuoted 10 lines · Serge Semin
Hi
Quoted 3 lines · Russell King (Oracle)
This is the second cleanup series for XPCS.
...
If you don't mind I'll test the series out on Monday or Tuesday on the next week after my local-tree changes concerning the DW XPCS driver are rebased onto it.
As promised just finished rebasing the series onto the kernel 6.12-rc2 and testing it out on the next HW setup:
DW XGMAC <-(XGMII)-> DW XPCS <-(10Gbase-R)-> Marvell 88x2222 <-(10gbase-r)->
SFP+ DAC SFP+
<-(10gbase-r)->
Marvell 88x2222 <-(10gbase-r)-> DW XPCS <-(XGMII)-> DW XGMAC
No problem has been spotted.
-Serge(y)
Quoted 16 lines
-Serge(y)
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/pcs/pcs-xpcs-nxp.c | 24 +- drivers/net/pcs/pcs-xpcs-wx.c | 56 ++- drivers/net/pcs/pcs-xpcs.c | 445 +++++++++------------- drivers/net/pcs/pcs-xpcs.h | 26 +- include/linux/pcs/pcs-xpcs.h | 19 +- 6 files changed, 237 insertions(+), 335 deletions(-)Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Russell King (Oracle)
reviewerQuoted 21 lines · Serge Semin
Quoted 10 lines · Serge Semin
Hi
Quoted 3 lines · Russell King (Oracle)
This is the second cleanup series for XPCS.
...
If you don't mind I'll test the series out on Monday or Tuesday on the next week after my local-tree changes concerning the DW XPCS driver are rebased onto it.
As promised just finished rebasing the series onto the kernel 6.12-rc2 and testing it out on the next HW setup:
DW XGMAC <-(XGMII)-> DW XPCS <-(10Gbase-R)-> Marvell 88x2222 <-(10gbase-r)->
SFP+ DAC SFP+
<-(10gbase-r)->
Marvell 88x2222 <-(10gbase-r)-> DW XPCS <-(XGMII)-> DW XGMAC
Quoted 3 lines
No problem has been spotted.
Tested-by Serge Semin <[email protected]>
Thanks. However, it looks like patchwork hasn't picked up your tested-by. Maybe it needs to be sent in reply to the cover message and not in a sub-thread?
https://patchwork.kernel.org/project/netdevbpf/list/?series=895512
Maybe netdev folk can add it?
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Quoted 27 lines · Russell King (Oracle)
Quoted 21 lines · Serge Semin
Quoted 10 lines · Serge Semin
Hi
Quoted 3 lines · Russell King (Oracle)
This is the second cleanup series for XPCS.
...
If you don't mind I'll test the series out on Monday or Tuesday on the next week after my local-tree changes concerning the DW XPCS driver are rebased onto it.
As promised just finished rebasing the series onto the kernel 6.12-rc2 and testing it out on the next HW setup:
DW XGMAC <-(XGMII)-> DW XPCS <-(10Gbase-R)-> Marvell 88x2222 <-(10gbase-r)->
SFP+ DAC SFP+
<-(10gbase-r)->
Marvell 88x2222 <-(10gbase-r)-> DW XPCS <-(XGMII)-> DW XGMACQuoted 3 lines
No problem has been spotted.
Tested-by Serge Semin <[email protected]>
Quoted 7 lines
Thanks. However, it looks like patchwork hasn't picked up your tested-by. Maybe it needs to be sent in reply to the cover message and not in a sub-thread?
https://patchwork.kernel.org/project/netdevbpf/list/?series=895512
Maybe netdev folk can add it?
Yeah, the tb-tag hasn't been added to the commits either:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=bb0b8aeca636373a9136a7a5b7594031c7587c5e
Likely you are right and the patchwork just doesn't detect the sub-replies tags. In the meantime the b4-tool does pick them up. I've just tested it.
-Serge(y)
Quoted 4 lines
Signature · 3 lines
-- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 9 lines · On Fri, 4 Oct 2024 11:19:57 +0100 you wrote:
This is the second cleanup series for XPCS.
Patch 1 removes the enum indexing the
dw_xpcs_compatarray. The index is never used except to place entries in the array and to size the array.Patch 2 removes the interface arrays - each of which only contain one interface.
[...]
Here is the summary with links:
- [net-next,01/13] net: pcs: xpcs: remove dw_xpcs_compat enum
https://git.kernel.org/netdev/net-next/c/e30993a9ab00 - [net-next,02/13] net: pcs: xpcs: don't use array for interface https://git.kernel.org/netdev/net-next/c/0397212f9306 - [net-next,03/13] net: pcs: xpcs: pass xpcs instead of xpcs->id to xpcs_find_compat() https://git.kernel.org/netdev/net-next/c/4490f5669b06 - [net-next,04/13] net: pcs: xpcs: provide a helper to get the phylink pcs given xpcs https://git.kernel.org/netdev/net-next/c/f042365a26b0 - [net-next,05/13] net: pcs: xpcs: move definition of struct dw_xpcs to private header https://git.kernel.org/netdev/net-next/c/accd5f5cd2e1 - [net-next,06/13] net: pcs: xpcs: rename xpcs_get_id() https://git.kernel.org/netdev/net-next/c/135d118bfd01 - [net-next,07/13] net: pcs: xpcs: move searching ID list out of line https://git.kernel.org/netdev/net-next/c/7921d3e602fc - [net-next,08/13] net: pcs: xpcs: use FIELD_PREP() and FIELD_GET() https://git.kernel.org/netdev/net-next/c/f68189181061 - [net-next,09/13] net: pcs: xpcs: add _modify() accessors https://git.kernel.org/netdev/net-next/c/ce8d6081fcf4 - [net-next,10/13] net: pcs: xpcs: convert to use read_poll_timeout() https://git.kernel.org/netdev/net-next/c/d69908faf132 - [net-next,11/13] net: pcs: xpcs: use dev_*() to print messages https://git.kernel.org/netdev/net-next/c/acb5fb5a42cf - [net-next,12/13] net: pcs: xpcs: correctly place DW_VR_MII_DIG_CTRL1_2G5_EN https://git.kernel.org/netdev/net-next/c/5ba561930390 - [net-next,13/13] net: pcs: xpcs: move Wangxun VR_XS_PCS_DIG_CTRL1 configuration https://git.kernel.org/netdev/net-next/c/bb0b8aeca636
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 47 lines · Russell King (Oracle)
This is the second cleanup series for XPCS.
Patch 1 removes the enum indexing the
dw_xpcs_compatarray. The index is never used except to place entries in the array and to size the array.Patch 2 removes the interface arrays - each of which only contain one interface.
Patch 3 makes
xpcs_find_compat()take the xpcs structure rather than the ID - the previous series removed the reason forxpcs_find_compatneeding to take the ID.Patch 4 provides a helper to convert xpcs structure to a regular
phylink_pcsstructure, which leads to patch 5.Patch 5 moves the definition of struct
dw_xpcsto the private xpcs header - with patch 4 in place, nothing outside of the xpcs driver accesses the contents of thedw_xpcsstructure.Patch 6 renames
xpcs_get_id()toxpcs_read_id()since it's reading the ID, rather than doing anything further with it. (Prior versions of this series renamed it toxpcs_read_phys_id()since that more accurately described that it was reading the physical ID registers.)Patch 7 moves the searching of the ID list out of line as this is a separate functional block.
Patch 8 converts xpcs to use the bitmap macros, which eliminates the need for
_SHIFTdefinitions.Patch 9 adds and uses
_modify()accessors as there are a large amount of read-modify-write operations in this driver. This conversion found a bug in xpcs-wx code that has been reported and already fixed.Patch 10 converts xpcs to use
read_poll_timeout()rather than open coding that.Patch 11 converts all printed messages to use the dev_*() functions so the driver and devie name are always printed.
Patch 12 moves
DW_VR_MII_DIG_CTRL1_2G5_ENto the correct place in the header file, rather than amongst another register's definitions.Patch 13 moves the Wangxun workaround to a common location rather than duplicating it in two places. We also reformat this to fit within 80 columns.
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 2 +- drivers/net/pcs/pcs-xpcs-nxp.c | 24 +- drivers/net/pcs/pcs-xpcs-wx.c | 56 ++- drivers/net/pcs/pcs-xpcs.c | 445 +++++++++------------- drivers/net/pcs/pcs-xpcs.h | 26 +- include/linux/pcs/pcs-xpcs.h | 19 +- 6 files changed, 237 insertions(+), 335 deletions(-)Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Late, I know, but: