* [net-next PATCH] net: dsa: qca8k: pack driver struct and improve cache use
@ 2022-02-27 23:48 Ansuel Smith
2022-02-28 3:12 ` Florian Fainelli
0 siblings, 1 reply; 2+ messages in thread
From: Ansuel Smith @ 2022-02-27 23:48 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
David S. Miller, Jakub Kicinski, Russell King, netdev,
linux-kernel
Cc: Ansuel Smith
Pack qca8k priv and other struct using pahole and set the first priv
struct entry to mgmt_master and mgmt_eth_data to speedup access.
While at it also rework pcs struct and move it qca8k_ports_config
following other configuration set for the cpu ports.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
drivers/net/dsa/qca8k.c | 8 ++++----
drivers/net/dsa/qca8k.h | 33 ++++++++++++++++-----------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index ee0dbf324268..83b11bb71a19 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -1685,11 +1685,11 @@ qca8k_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
case PHY_INTERFACE_MODE_1000BASEX:
switch (port) {
case 0:
- pcs = &priv->pcs_port_0.pcs;
+ pcs = &priv->ports_config.qpcs[QCA8K_CPU_PORT0].pcs;
break;
case 6:
- pcs = &priv->pcs_port_6.pcs;
+ pcs = &priv->ports_config.qpcs[QCA8K_CPU_PORT6].pcs;
break;
}
break;
@@ -2889,8 +2889,8 @@ qca8k_setup(struct dsa_switch *ds)
if (ret)
return ret;
- qca8k_setup_pcs(priv, &priv->pcs_port_0, 0);
- qca8k_setup_pcs(priv, &priv->pcs_port_6, 6);
+ qca8k_setup_pcs(priv, &priv->ports_config.qpcs[QCA8K_CPU_PORT0], 0);
+ qca8k_setup_pcs(priv, &priv->ports_config.qpcs[QCA8K_CPU_PORT0], 6);
/* Make sure MAC06 is disabled */
ret = regmap_clear_bits(priv->regmap, QCA8K_REG_PORT0_PAD_CTRL,
diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
index f375627174c8..611dc2335dbe 100644
--- a/drivers/net/dsa/qca8k.h
+++ b/drivers/net/dsa/qca8k.h
@@ -341,18 +341,24 @@ enum {
struct qca8k_mgmt_eth_data {
struct completion rw_done;
- struct mutex mutex; /* Enforce one mdio read/write at time */
+ u32 data[4];
bool ack;
u32 seq;
- u32 data[4];
+ struct mutex mutex; /* Enforce one mdio read/write at time */
};
struct qca8k_mib_eth_data {
struct completion rw_done;
+ u64 *data; /* pointer to ethtool data */
+ u8 req_port;
struct mutex mutex; /* Process one command at time */
refcount_t port_parsed; /* Counter to track parsed port */
- u8 req_port;
- u64 *data; /* pointer to ethtool data */
+};
+
+struct qca8k_pcs {
+ struct phylink_pcs pcs;
+ struct qca8k_priv *priv;
+ int port;
};
struct qca8k_ports_config {
@@ -361,6 +367,7 @@ struct qca8k_ports_config {
bool sgmii_enable_pll;
u8 rgmii_rx_delay[QCA8K_NUM_CPU_PORTS]; /* 0: CPU port0, 1: CPU port6 */
u8 rgmii_tx_delay[QCA8K_NUM_CPU_PORTS]; /* 0: CPU port0, 1: CPU port6 */
+ struct qca8k_pcs qpcs[QCA8K_NUM_CPU_PORTS];
};
struct qca8k_mdio_cache {
@@ -376,13 +383,10 @@ struct qca8k_mdio_cache {
u16 hi;
};
-struct qca8k_pcs {
- struct phylink_pcs pcs;
- struct qca8k_priv *priv;
- int port;
-};
-
struct qca8k_priv {
+ struct net_device *mgmt_master; /* Track if mdio/mib Ethernet is available */
+ struct qca8k_mgmt_eth_data mgmt_eth_data;
+ struct qca8k_mdio_cache mdio_cache;
u8 switch_id;
u8 switch_revision;
u8 mirror_rx;
@@ -396,15 +400,10 @@ struct qca8k_priv {
struct dsa_switch *ds;
struct mutex reg_mutex;
struct device *dev;
- struct dsa_switch_ops ops;
struct gpio_desc *reset_gpio;
- unsigned int port_mtu[QCA8K_NUM_PORTS];
- struct net_device *mgmt_master; /* Track if mdio/mib Ethernet is available */
- struct qca8k_mgmt_eth_data mgmt_eth_data;
+ struct dsa_switch_ops ops;
struct qca8k_mib_eth_data mib_eth_data;
- struct qca8k_mdio_cache mdio_cache;
- struct qca8k_pcs pcs_port_0;
- struct qca8k_pcs pcs_port_6;
+ unsigned int port_mtu[QCA8K_NUM_PORTS];
};
struct qca8k_mib_desc {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [net-next PATCH] net: dsa: qca8k: pack driver struct and improve cache use
2022-02-27 23:48 [net-next PATCH] net: dsa: qca8k: pack driver struct and improve cache use Ansuel Smith
@ 2022-02-28 3:12 ` Florian Fainelli
0 siblings, 0 replies; 2+ messages in thread
From: Florian Fainelli @ 2022-02-28 3:12 UTC (permalink / raw)
To: Ansuel Smith, Andrew Lunn, Vivien Didelot, Vladimir Oltean,
David S. Miller, Jakub Kicinski, Russell King, netdev,
linux-kernel
On 2/27/2022 15:48, Ansuel Smith wrote:
> Pack qca8k priv and other struct using pahole and set the first priv
> struct entry to mgmt_master and mgmt_eth_data to speedup access.
> While at it also rework pcs struct and move it qca8k_ports_config
> following other configuration set for the cpu ports.
>
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
> drivers/net/dsa/qca8k.c | 8 ++++----
> drivers/net/dsa/qca8k.h | 33 ++++++++++++++++-----------------
> 2 files changed, 20 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index ee0dbf324268..83b11bb71a19 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -1685,11 +1685,11 @@ qca8k_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
> case PHY_INTERFACE_MODE_1000BASEX:
> switch (port) {
> case 0:
> - pcs = &priv->pcs_port_0.pcs;
> + pcs = &priv->ports_config.qpcs[QCA8K_CPU_PORT0].pcs;
> break;
>
> case 6:
> - pcs = &priv->pcs_port_6.pcs;
> + pcs = &priv->ports_config.qpcs[QCA8K_CPU_PORT6].pcs;
> break;
> }
> break;
> @@ -2889,8 +2889,8 @@ qca8k_setup(struct dsa_switch *ds)
> if (ret)
> return ret;
>
> - qca8k_setup_pcs(priv, &priv->pcs_port_0, 0);
> - qca8k_setup_pcs(priv, &priv->pcs_port_6, 6);
> + qca8k_setup_pcs(priv, &priv->ports_config.qpcs[QCA8K_CPU_PORT0], 0);
> + qca8k_setup_pcs(priv, &priv->ports_config.qpcs[QCA8K_CPU_PORT0], 6);
Should this be QCA8K_CPU_PORT6?
--
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-28 3:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-27 23:48 [net-next PATCH] net: dsa: qca8k: pack driver struct and improve cache use Ansuel Smith
2022-02-28 3:12 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).