Commit 070a5e62 authored by Furong Xu's avatar Furong Xu Committed by Jakub Kicinski

net: stmmac: move stmmac_fpe_cfg to stmmac_priv data

By moving the fpe_cfg field to the stmmac_priv data, stmmac_fpe_cfg
becomes platform-data eventually, instead of a run-time config.
Suggested-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Signed-off-by: default avatarFurong Xu <0x1207@gmail.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Link: https://patch.msgid.link/d9b3d7ecb308c5e39778a4c8ae9df288a2754379.1725631883.git.0x1207@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 525034e2
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
struct stmmac_extra_stats; struct stmmac_extra_stats;
struct stmmac_priv; struct stmmac_priv;
struct stmmac_safety_stats; struct stmmac_safety_stats;
struct stmmac_fpe_cfg;
enum stmmac_mpacket_type;
struct dma_desc; struct dma_desc;
struct dma_extended_desc; struct dma_extended_desc;
struct dma_edesc; struct dma_edesc;
......
...@@ -146,6 +146,33 @@ struct stmmac_channel { ...@@ -146,6 +146,33 @@ struct stmmac_channel {
u32 index; u32 index;
}; };
/* FPE link state */
enum stmmac_fpe_state {
FPE_STATE_OFF = 0,
FPE_STATE_CAPABLE = 1,
FPE_STATE_ENTERING_ON = 2,
FPE_STATE_ON = 3,
};
/* FPE link-partner hand-shaking mPacket type */
enum stmmac_mpacket_type {
MPACKET_VERIFY = 0,
MPACKET_RESPONSE = 1,
};
enum stmmac_fpe_task_state_t {
__FPE_REMOVING,
__FPE_TASK_SCHED,
};
struct stmmac_fpe_cfg {
bool enable; /* FPE enable */
bool hs_enable; /* FPE handshake enable */
enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */
enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */
u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */
};
struct stmmac_tc_entry { struct stmmac_tc_entry {
bool in_use; bool in_use;
bool in_hw; bool in_hw;
...@@ -339,11 +366,12 @@ struct stmmac_priv { ...@@ -339,11 +366,12 @@ struct stmmac_priv {
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct work_struct service_task; struct work_struct service_task;
/* Workqueue for handling FPE hand-shaking */ /* Frame Preemption feature (FPE) */
unsigned long fpe_task_state; unsigned long fpe_task_state;
struct workqueue_struct *fpe_wq; struct workqueue_struct *fpe_wq;
struct work_struct fpe_task; struct work_struct fpe_task;
char wq_name[IFNAMSIZ + 4]; char wq_name[IFNAMSIZ + 4];
struct stmmac_fpe_cfg fpe_cfg;
/* TC Handling */ /* TC Handling */
unsigned int tc_entries_max; unsigned int tc_entries_max;
......
...@@ -968,7 +968,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, ...@@ -968,7 +968,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up)
{ {
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
bool *hs_enable = &fpe_cfg->hs_enable; bool *hs_enable = &fpe_cfg->hs_enable;
...@@ -3536,7 +3536,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) ...@@ -3536,7 +3536,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
if (priv->dma_cap.fpesel) { if (priv->dma_cap.fpesel) {
stmmac_fpe_start_wq(priv); stmmac_fpe_start_wq(priv);
if (priv->plat->fpe_cfg->enable) if (priv->fpe_cfg.enable)
stmmac_fpe_handshake(priv, true); stmmac_fpe_handshake(priv, true);
} }
...@@ -5982,7 +5982,7 @@ static int stmmac_set_features(struct net_device *netdev, ...@@ -5982,7 +5982,7 @@ static int stmmac_set_features(struct net_device *netdev,
static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status)
{ {
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
bool *hs_enable = &fpe_cfg->hs_enable; bool *hs_enable = &fpe_cfg->hs_enable;
...@@ -7381,7 +7381,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work) ...@@ -7381,7 +7381,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work)
{ {
struct stmmac_priv *priv = container_of(work, struct stmmac_priv, struct stmmac_priv *priv = container_of(work, struct stmmac_priv,
fpe_task); fpe_task);
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
bool *hs_enable = &fpe_cfg->hs_enable; bool *hs_enable = &fpe_cfg->hs_enable;
...@@ -7427,17 +7427,17 @@ static void stmmac_fpe_lp_task(struct work_struct *work) ...@@ -7427,17 +7427,17 @@ static void stmmac_fpe_lp_task(struct work_struct *work)
void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable) void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable)
{ {
if (priv->plat->fpe_cfg->hs_enable != enable) { if (priv->fpe_cfg.hs_enable != enable) {
if (enable) { if (enable) {
stmmac_fpe_send_mpacket(priv, priv->ioaddr, stmmac_fpe_send_mpacket(priv, priv->ioaddr,
priv->plat->fpe_cfg, &priv->fpe_cfg,
MPACKET_VERIFY); MPACKET_VERIFY);
} else { } else {
priv->plat->fpe_cfg->lo_fpe_state = FPE_STATE_OFF; priv->fpe_cfg.lo_fpe_state = FPE_STATE_OFF;
priv->plat->fpe_cfg->lp_fpe_state = FPE_STATE_OFF; priv->fpe_cfg.lp_fpe_state = FPE_STATE_OFF;
} }
priv->plat->fpe_cfg->hs_enable = enable; priv->fpe_cfg.hs_enable = enable;
} }
} }
...@@ -7898,7 +7898,7 @@ int stmmac_suspend(struct device *dev) ...@@ -7898,7 +7898,7 @@ int stmmac_suspend(struct device *dev)
if (priv->dma_cap.fpesel) { if (priv->dma_cap.fpesel) {
/* Disable FPE */ /* Disable FPE */
stmmac_fpe_configure(priv, priv->ioaddr, stmmac_fpe_configure(priv, priv->ioaddr,
priv->plat->fpe_cfg, &priv->fpe_cfg,
priv->plat->tx_queues_to_use, priv->plat->tx_queues_to_use,
priv->plat->rx_queues_to_use, false); priv->plat->rx_queues_to_use, false);
......
...@@ -282,16 +282,6 @@ static int tc_init(struct stmmac_priv *priv) ...@@ -282,16 +282,6 @@ static int tc_init(struct stmmac_priv *priv)
if (ret) if (ret)
return -ENOMEM; return -ENOMEM;
if (!priv->plat->fpe_cfg) {
priv->plat->fpe_cfg = devm_kzalloc(priv->device,
sizeof(*priv->plat->fpe_cfg),
GFP_KERNEL);
if (!priv->plat->fpe_cfg)
return -ENOMEM;
} else {
memset(priv->plat->fpe_cfg, 0, sizeof(*priv->plat->fpe_cfg));
}
/* Fail silently as we can still use remaining features, e.g. CBS */ /* Fail silently as we can still use remaining features, e.g. CBS */
if (!dma_cap->frpsel) if (!dma_cap->frpsel)
return 0; return 0;
...@@ -1076,7 +1066,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, ...@@ -1076,7 +1066,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
/* Actual FPE register configuration will be done after FPE handshake /* Actual FPE register configuration will be done after FPE handshake
* is success. * is success.
*/ */
priv->plat->fpe_cfg->enable = fpe; priv->fpe_cfg.enable = fpe;
ret = stmmac_est_configure(priv, priv, priv->est, ret = stmmac_est_configure(priv, priv, priv->est,
priv->plat->clk_ptp_rate); priv->plat->clk_ptp_rate);
...@@ -1109,9 +1099,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv, ...@@ -1109,9 +1099,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
mutex_unlock(&priv->est_lock); mutex_unlock(&priv->est_lock);
} }
priv->plat->fpe_cfg->enable = false; priv->fpe_cfg.enable = false;
stmmac_fpe_configure(priv, priv->ioaddr, stmmac_fpe_configure(priv, priv->ioaddr,
priv->plat->fpe_cfg, &priv->fpe_cfg,
priv->plat->tx_queues_to_use, priv->plat->tx_queues_to_use,
priv->plat->rx_queues_to_use, priv->plat->rx_queues_to_use,
false); false);
......
...@@ -138,33 +138,6 @@ struct stmmac_txq_cfg { ...@@ -138,33 +138,6 @@ struct stmmac_txq_cfg {
int tbs_en; int tbs_en;
}; };
/* FPE link state */
enum stmmac_fpe_state {
FPE_STATE_OFF = 0,
FPE_STATE_CAPABLE = 1,
FPE_STATE_ENTERING_ON = 2,
FPE_STATE_ON = 3,
};
/* FPE link-partner hand-shaking mPacket type */
enum stmmac_mpacket_type {
MPACKET_VERIFY = 0,
MPACKET_RESPONSE = 1,
};
enum stmmac_fpe_task_state_t {
__FPE_REMOVING,
__FPE_TASK_SCHED,
};
struct stmmac_fpe_cfg {
bool enable; /* FPE enable */
bool hs_enable; /* FPE handshake enable */
enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */
enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */
u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */
};
struct stmmac_safety_feature_cfg { struct stmmac_safety_feature_cfg {
u32 tsoee; u32 tsoee;
u32 mrxpee; u32 mrxpee;
...@@ -232,7 +205,6 @@ struct plat_stmmacenet_data { ...@@ -232,7 +205,6 @@ struct plat_stmmacenet_data {
struct fwnode_handle *port_node; struct fwnode_handle *port_node;
struct device_node *mdio_node; struct device_node *mdio_node;
struct stmmac_dma_cfg *dma_cfg; struct stmmac_dma_cfg *dma_cfg;
struct stmmac_fpe_cfg *fpe_cfg;
struct stmmac_safety_feature_cfg *safety_feat_cfg; struct stmmac_safety_feature_cfg *safety_feat_cfg;
int clk_csr; int clk_csr;
int has_gmac; int has_gmac;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment