Skip to content

Commit bd17382

Browse files
xiaoleiwang123456kuba-moo
authored andcommitted
net: stmmac: move the EST structure to struct stmmac_priv
Move the EST structure to struct stmmac_priv, because the EST configs don't look like platform config, but EST is enabled in runtime with the settings retrieved for the TC TAPRIO feature also in runtime. So it's better to have the EST-data preserved in the driver private data instead of the platform data storage. Signed-off-by: Xiaolei Wang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Serge Semin <[email protected]> Reviewed-by: Andrew Halaney <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 36ac9e7 commit bd17382

File tree

5 files changed

+54
-56
lines changed

5 files changed

+54
-56
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ struct stmmac_dma_conf {
221221
unsigned int dma_tx_size;
222222
};
223223

224+
#define EST_GCL 1024
225+
struct stmmac_est {
226+
int enable;
227+
u32 btr_reserve[2];
228+
u32 btr_offset[2];
229+
u32 btr[2];
230+
u32 ctr[2];
231+
u32 ter;
232+
u32 gcl_unaligned[EST_GCL];
233+
u32 gcl[EST_GCL];
234+
u32 gcl_size;
235+
u32 max_sdu[MTL_MAX_TX_QUEUES];
236+
};
237+
224238
struct stmmac_priv {
225239
/* Frequently used values are kept adjacent for cache effect */
226240
u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
@@ -263,6 +277,7 @@ struct stmmac_priv {
263277
struct plat_stmmacenet_data *plat;
264278
/* Protect est parameters */
265279
struct mutex est_lock;
280+
struct stmmac_est *est;
266281
struct dma_features dma_cap;
267282
struct stmmac_counters mmc;
268283
int hw_cap_support;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,9 +2498,9 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
24982498
if (!xsk_tx_peek_desc(pool, &xdp_desc))
24992499
break;
25002500

2501-
if (priv->plat->est && priv->plat->est->enable &&
2502-
priv->plat->est->max_sdu[queue] &&
2503-
xdp_desc.len > priv->plat->est->max_sdu[queue]) {
2501+
if (priv->est && priv->est->enable &&
2502+
priv->est->max_sdu[queue] &&
2503+
xdp_desc.len > priv->est->max_sdu[queue]) {
25042504
priv->xstats.max_sdu_txq_drop[queue]++;
25052505
continue;
25062506
}
@@ -4538,9 +4538,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
45384538
return stmmac_tso_xmit(skb, dev);
45394539
}
45404540

4541-
if (priv->plat->est && priv->plat->est->enable &&
4542-
priv->plat->est->max_sdu[queue] &&
4543-
skb->len > priv->plat->est->max_sdu[queue]){
4541+
if (priv->est && priv->est->enable &&
4542+
priv->est->max_sdu[queue] &&
4543+
skb->len > priv->est->max_sdu[queue]){
45444544
priv->xstats.max_sdu_txq_drop[queue]++;
45454545
goto max_sdu_err;
45464546
}
@@ -4919,9 +4919,9 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
49194919
if (stmmac_tx_avail(priv, queue) < STMMAC_TX_THRESH(priv))
49204920
return STMMAC_XDP_CONSUMED;
49214921

4922-
if (priv->plat->est && priv->plat->est->enable &&
4923-
priv->plat->est->max_sdu[queue] &&
4924-
xdpf->len > priv->plat->est->max_sdu[queue]) {
4922+
if (priv->est && priv->est->enable &&
4923+
priv->est->max_sdu[queue] &&
4924+
xdpf->len > priv->est->max_sdu[queue]) {
49254925
priv->xstats.max_sdu_txq_drop[queue]++;
49264926
return STMMAC_XDP_CONSUMED;
49274927
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
6868
nsec = reminder;
6969

7070
/* If EST is enabled, disabled it before adjust ptp time. */
71-
if (priv->plat->est && priv->plat->est->enable) {
71+
if (priv->est && priv->est->enable) {
7272
est_rst = true;
7373
mutex_lock(&priv->est_lock);
74-
priv->plat->est->enable = false;
75-
stmmac_est_configure(priv, priv, priv->plat->est,
74+
priv->est->enable = false;
75+
stmmac_est_configure(priv, priv, priv->est,
7676
priv->plat->clk_ptp_rate);
7777
mutex_unlock(&priv->est_lock);
7878
}
@@ -90,19 +90,19 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
9090
mutex_lock(&priv->est_lock);
9191
priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, &current_time);
9292
current_time_ns = timespec64_to_ktime(current_time);
93-
time.tv_nsec = priv->plat->est->btr_reserve[0];
94-
time.tv_sec = priv->plat->est->btr_reserve[1];
93+
time.tv_nsec = priv->est->btr_reserve[0];
94+
time.tv_sec = priv->est->btr_reserve[1];
9595
basetime = timespec64_to_ktime(time);
96-
cycle_time = (u64)priv->plat->est->ctr[1] * NSEC_PER_SEC +
97-
priv->plat->est->ctr[0];
96+
cycle_time = (u64)priv->est->ctr[1] * NSEC_PER_SEC +
97+
priv->est->ctr[0];
9898
time = stmmac_calc_tas_basetime(basetime,
9999
current_time_ns,
100100
cycle_time);
101101

102-
priv->plat->est->btr[0] = (u32)time.tv_nsec;
103-
priv->plat->est->btr[1] = (u32)time.tv_sec;
104-
priv->plat->est->enable = true;
105-
ret = stmmac_est_configure(priv, priv, priv->plat->est,
102+
priv->est->btr[0] = (u32)time.tv_nsec;
103+
priv->est->btr[1] = (u32)time.tv_sec;
104+
priv->est->enable = true;
105+
ret = stmmac_est_configure(priv, priv, priv->est,
106106
priv->plat->clk_ptp_rate);
107107
mutex_unlock(&priv->est_lock);
108108
if (ret)

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

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,6 @@ struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time,
918918
static void tc_taprio_map_maxsdu_txq(struct stmmac_priv *priv,
919919
struct tc_taprio_qopt_offload *qopt)
920920
{
921-
struct plat_stmmacenet_data *plat = priv->plat;
922921
u32 num_tc = qopt->mqprio.qopt.num_tc;
923922
u32 offset, count, i, j;
924923

@@ -933,15 +932,14 @@ static void tc_taprio_map_maxsdu_txq(struct stmmac_priv *priv,
933932
count = qopt->mqprio.qopt.count[i];
934933

935934
for (j = offset; j < offset + count; j++)
936-
plat->est->max_sdu[j] = qopt->max_sdu[i] + ETH_HLEN - ETH_TLEN;
935+
priv->est->max_sdu[j] = qopt->max_sdu[i] + ETH_HLEN - ETH_TLEN;
937936
}
938937
}
939938

940939
static int tc_taprio_configure(struct stmmac_priv *priv,
941940
struct tc_taprio_qopt_offload *qopt)
942941
{
943942
u32 size, wid = priv->dma_cap.estwid, dep = priv->dma_cap.estdep;
944-
struct plat_stmmacenet_data *plat = priv->plat;
945943
struct timespec64 time, current_time, qopt_time;
946944
ktime_t current_time_ns;
947945
bool fpe = false;
@@ -998,24 +996,24 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
998996
if (qopt->cycle_time_extension >= BIT(wid + 7))
999997
return -ERANGE;
1000998

1001-
if (!plat->est) {
1002-
plat->est = devm_kzalloc(priv->device, sizeof(*plat->est),
999+
if (!priv->est) {
1000+
priv->est = devm_kzalloc(priv->device, sizeof(*priv->est),
10031001
GFP_KERNEL);
1004-
if (!plat->est)
1002+
if (!priv->est)
10051003
return -ENOMEM;
10061004

10071005
mutex_init(&priv->est_lock);
10081006
} else {
10091007
mutex_lock(&priv->est_lock);
1010-
memset(plat->est, 0, sizeof(*plat->est));
1008+
memset(priv->est, 0, sizeof(*priv->est));
10111009
mutex_unlock(&priv->est_lock);
10121010
}
10131011

10141012
size = qopt->num_entries;
10151013

10161014
mutex_lock(&priv->est_lock);
1017-
priv->plat->est->gcl_size = size;
1018-
priv->plat->est->enable = qopt->cmd == TAPRIO_CMD_REPLACE;
1015+
priv->est->gcl_size = size;
1016+
priv->est->enable = qopt->cmd == TAPRIO_CMD_REPLACE;
10191017
mutex_unlock(&priv->est_lock);
10201018

10211019
for (i = 0; i < size; i++) {
@@ -1044,7 +1042,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
10441042
return -EOPNOTSUPP;
10451043
}
10461044

1047-
priv->plat->est->gcl[i] = delta_ns | (gates << wid);
1045+
priv->est->gcl[i] = delta_ns | (gates << wid);
10481046
}
10491047

10501048
mutex_lock(&priv->est_lock);
@@ -1054,18 +1052,18 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
10541052
time = stmmac_calc_tas_basetime(qopt->base_time, current_time_ns,
10551053
qopt->cycle_time);
10561054

1057-
priv->plat->est->btr[0] = (u32)time.tv_nsec;
1058-
priv->plat->est->btr[1] = (u32)time.tv_sec;
1055+
priv->est->btr[0] = (u32)time.tv_nsec;
1056+
priv->est->btr[1] = (u32)time.tv_sec;
10591057

10601058
qopt_time = ktime_to_timespec64(qopt->base_time);
1061-
priv->plat->est->btr_reserve[0] = (u32)qopt_time.tv_nsec;
1062-
priv->plat->est->btr_reserve[1] = (u32)qopt_time.tv_sec;
1059+
priv->est->btr_reserve[0] = (u32)qopt_time.tv_nsec;
1060+
priv->est->btr_reserve[1] = (u32)qopt_time.tv_sec;
10631061

10641062
ctr = qopt->cycle_time;
1065-
priv->plat->est->ctr[0] = do_div(ctr, NSEC_PER_SEC);
1066-
priv->plat->est->ctr[1] = (u32)ctr;
1063+
priv->est->ctr[0] = do_div(ctr, NSEC_PER_SEC);
1064+
priv->est->ctr[1] = (u32)ctr;
10671065

1068-
priv->plat->est->ter = qopt->cycle_time_extension;
1066+
priv->est->ter = qopt->cycle_time_extension;
10691067

10701068
tc_taprio_map_maxsdu_txq(priv, qopt);
10711069

@@ -1079,7 +1077,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
10791077
*/
10801078
priv->plat->fpe_cfg->enable = fpe;
10811079

1082-
ret = stmmac_est_configure(priv, priv, priv->plat->est,
1080+
ret = stmmac_est_configure(priv, priv, priv->est,
10831081
priv->plat->clk_ptp_rate);
10841082
mutex_unlock(&priv->est_lock);
10851083
if (ret) {
@@ -1097,10 +1095,10 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
10971095
return 0;
10981096

10991097
disable:
1100-
if (priv->plat->est) {
1098+
if (priv->est) {
11011099
mutex_lock(&priv->est_lock);
1102-
priv->plat->est->enable = false;
1103-
stmmac_est_configure(priv, priv, priv->plat->est,
1100+
priv->est->enable = false;
1101+
stmmac_est_configure(priv, priv, priv->est,
11041102
priv->plat->clk_ptp_rate);
11051103
/* Reset taprio status */
11061104
for (i = 0; i < priv->plat->tx_queues_to_use; i++) {

include/linux/stmmac.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,6 @@ struct stmmac_axi {
115115
bool axi_rb;
116116
};
117117

118-
#define EST_GCL 1024
119-
struct stmmac_est {
120-
int enable;
121-
u32 btr_reserve[2];
122-
u32 btr_offset[2];
123-
u32 btr[2];
124-
u32 ctr[2];
125-
u32 ter;
126-
u32 gcl_unaligned[EST_GCL];
127-
u32 gcl[EST_GCL];
128-
u32 gcl_size;
129-
u32 max_sdu[MTL_MAX_TX_QUEUES];
130-
};
131-
132118
struct stmmac_rxq_cfg {
133119
u8 mode_to_use;
134120
u32 chan;
@@ -245,7 +231,6 @@ struct plat_stmmacenet_data {
245231
struct fwnode_handle *port_node;
246232
struct device_node *mdio_node;
247233
struct stmmac_dma_cfg *dma_cfg;
248-
struct stmmac_est *est;
249234
struct stmmac_fpe_cfg *fpe_cfg;
250235
struct stmmac_safety_feature_cfg *safety_feat_cfg;
251236
int clk_csr;

0 commit comments

Comments
 (0)