Skip to content

Commit 070a5e6

Browse files
Furong Xukuba-moo
authored andcommitted
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: Serge Semin <[email protected]> Signed-off-by: Furong Xu <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Reviewed-by: Serge Semin <[email protected]> Link: https://patch.msgid.link/d9b3d7ecb308c5e39778a4c8ae9df288a2754379.1725631883.git.0x1207@gmail.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 525034e commit 070a5e6

File tree

5 files changed

+44
-52
lines changed

5 files changed

+44
-52
lines changed

drivers/net/ethernet/stmicro/stmmac/hwif.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
struct stmmac_extra_stats;
2929
struct stmmac_priv;
3030
struct stmmac_safety_stats;
31+
struct stmmac_fpe_cfg;
32+
enum stmmac_mpacket_type;
3133
struct dma_desc;
3234
struct dma_extended_desc;
3335
struct dma_edesc;

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,33 @@ struct stmmac_channel {
146146
u32 index;
147147
};
148148

149+
/* FPE link state */
150+
enum stmmac_fpe_state {
151+
FPE_STATE_OFF = 0,
152+
FPE_STATE_CAPABLE = 1,
153+
FPE_STATE_ENTERING_ON = 2,
154+
FPE_STATE_ON = 3,
155+
};
156+
157+
/* FPE link-partner hand-shaking mPacket type */
158+
enum stmmac_mpacket_type {
159+
MPACKET_VERIFY = 0,
160+
MPACKET_RESPONSE = 1,
161+
};
162+
163+
enum stmmac_fpe_task_state_t {
164+
__FPE_REMOVING,
165+
__FPE_TASK_SCHED,
166+
};
167+
168+
struct stmmac_fpe_cfg {
169+
bool enable; /* FPE enable */
170+
bool hs_enable; /* FPE handshake enable */
171+
enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */
172+
enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */
173+
u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */
174+
};
175+
149176
struct stmmac_tc_entry {
150177
bool in_use;
151178
bool in_hw;
@@ -339,11 +366,12 @@ struct stmmac_priv {
339366
struct workqueue_struct *wq;
340367
struct work_struct service_task;
341368

342-
/* Workqueue for handling FPE hand-shaking */
369+
/* Frame Preemption feature (FPE) */
343370
unsigned long fpe_task_state;
344371
struct workqueue_struct *fpe_wq;
345372
struct work_struct fpe_task;
346373
char wq_name[IFNAMSIZ + 4];
374+
struct stmmac_fpe_cfg fpe_cfg;
347375

348376
/* TC Handling */
349377
unsigned int tc_entries_max;

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
968968

969969
static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up)
970970
{
971-
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg;
971+
struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
972972
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
973973
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
974974
bool *hs_enable = &fpe_cfg->hs_enable;
@@ -3536,7 +3536,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
35363536
if (priv->dma_cap.fpesel) {
35373537
stmmac_fpe_start_wq(priv);
35383538

3539-
if (priv->plat->fpe_cfg->enable)
3539+
if (priv->fpe_cfg.enable)
35403540
stmmac_fpe_handshake(priv, true);
35413541
}
35423542

@@ -5982,7 +5982,7 @@ static int stmmac_set_features(struct net_device *netdev,
59825982

59835983
static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status)
59845984
{
5985-
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg;
5985+
struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
59865986
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
59875987
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
59885988
bool *hs_enable = &fpe_cfg->hs_enable;
@@ -7381,7 +7381,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work)
73817381
{
73827382
struct stmmac_priv *priv = container_of(work, struct stmmac_priv,
73837383
fpe_task);
7384-
struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg;
7384+
struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
73857385
enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state;
73867386
enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state;
73877387
bool *hs_enable = &fpe_cfg->hs_enable;
@@ -7427,17 +7427,17 @@ static void stmmac_fpe_lp_task(struct work_struct *work)
74277427

74287428
void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable)
74297429
{
7430-
if (priv->plat->fpe_cfg->hs_enable != enable) {
7430+
if (priv->fpe_cfg.hs_enable != enable) {
74317431
if (enable) {
74327432
stmmac_fpe_send_mpacket(priv, priv->ioaddr,
7433-
priv->plat->fpe_cfg,
7433+
&priv->fpe_cfg,
74347434
MPACKET_VERIFY);
74357435
} else {
7436-
priv->plat->fpe_cfg->lo_fpe_state = FPE_STATE_OFF;
7437-
priv->plat->fpe_cfg->lp_fpe_state = FPE_STATE_OFF;
7436+
priv->fpe_cfg.lo_fpe_state = FPE_STATE_OFF;
7437+
priv->fpe_cfg.lp_fpe_state = FPE_STATE_OFF;
74387438
}
74397439

7440-
priv->plat->fpe_cfg->hs_enable = enable;
7440+
priv->fpe_cfg.hs_enable = enable;
74417441
}
74427442
}
74437443

@@ -7898,7 +7898,7 @@ int stmmac_suspend(struct device *dev)
78987898
if (priv->dma_cap.fpesel) {
78997899
/* Disable FPE */
79007900
stmmac_fpe_configure(priv, priv->ioaddr,
7901-
priv->plat->fpe_cfg,
7901+
&priv->fpe_cfg,
79027902
priv->plat->tx_queues_to_use,
79037903
priv->plat->rx_queues_to_use, false);
79047904

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,6 @@ static int tc_init(struct stmmac_priv *priv)
282282
if (ret)
283283
return -ENOMEM;
284284

285-
if (!priv->plat->fpe_cfg) {
286-
priv->plat->fpe_cfg = devm_kzalloc(priv->device,
287-
sizeof(*priv->plat->fpe_cfg),
288-
GFP_KERNEL);
289-
if (!priv->plat->fpe_cfg)
290-
return -ENOMEM;
291-
} else {
292-
memset(priv->plat->fpe_cfg, 0, sizeof(*priv->plat->fpe_cfg));
293-
}
294-
295285
/* Fail silently as we can still use remaining features, e.g. CBS */
296286
if (!dma_cap->frpsel)
297287
return 0;
@@ -1076,7 +1066,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
10761066
/* Actual FPE register configuration will be done after FPE handshake
10771067
* is success.
10781068
*/
1079-
priv->plat->fpe_cfg->enable = fpe;
1069+
priv->fpe_cfg.enable = fpe;
10801070

10811071
ret = stmmac_est_configure(priv, priv, priv->est,
10821072
priv->plat->clk_ptp_rate);
@@ -1109,9 +1099,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
11091099
mutex_unlock(&priv->est_lock);
11101100
}
11111101

1112-
priv->plat->fpe_cfg->enable = false;
1102+
priv->fpe_cfg.enable = false;
11131103
stmmac_fpe_configure(priv, priv->ioaddr,
1114-
priv->plat->fpe_cfg,
1104+
&priv->fpe_cfg,
11151105
priv->plat->tx_queues_to_use,
11161106
priv->plat->rx_queues_to_use,
11171107
false);

include/linux/stmmac.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,33 +138,6 @@ struct stmmac_txq_cfg {
138138
int tbs_en;
139139
};
140140

141-
/* FPE link state */
142-
enum stmmac_fpe_state {
143-
FPE_STATE_OFF = 0,
144-
FPE_STATE_CAPABLE = 1,
145-
FPE_STATE_ENTERING_ON = 2,
146-
FPE_STATE_ON = 3,
147-
};
148-
149-
/* FPE link-partner hand-shaking mPacket type */
150-
enum stmmac_mpacket_type {
151-
MPACKET_VERIFY = 0,
152-
MPACKET_RESPONSE = 1,
153-
};
154-
155-
enum stmmac_fpe_task_state_t {
156-
__FPE_REMOVING,
157-
__FPE_TASK_SCHED,
158-
};
159-
160-
struct stmmac_fpe_cfg {
161-
bool enable; /* FPE enable */
162-
bool hs_enable; /* FPE handshake enable */
163-
enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */
164-
enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */
165-
u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */
166-
};
167-
168141
struct stmmac_safety_feature_cfg {
169142
u32 tsoee;
170143
u32 mrxpee;
@@ -232,7 +205,6 @@ struct plat_stmmacenet_data {
232205
struct fwnode_handle *port_node;
233206
struct device_node *mdio_node;
234207
struct stmmac_dma_cfg *dma_cfg;
235-
struct stmmac_fpe_cfg *fpe_cfg;
236208
struct stmmac_safety_feature_cfg *safety_feat_cfg;
237209
int clk_csr;
238210
int has_gmac;

0 commit comments

Comments
 (0)