Commit 430b383c authored by Jose Abreu's avatar Jose Abreu Committed by Jakub Kicinski

net: stmmac: tc: Add support for ETF Scheduler using TBS

Adds the support for ETF scheduler using TBS feature which is available
in XGMAC and QoS IPs.

Changes from v2:
- Fix checkpatch issues (Jakub)
- Use the TBS bitfield
Signed-off-by: default avatarJose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 579a25a8
...@@ -368,6 +368,7 @@ struct dma_features { ...@@ -368,6 +368,7 @@ struct dma_features {
unsigned int estdep; unsigned int estdep;
unsigned int estsel; unsigned int estsel;
unsigned int fpesel; unsigned int fpesel;
unsigned int tbssel;
}; };
/* RX Buffer size must be multiple of 4/8/16 bytes */ /* RX Buffer size must be multiple of 4/8/16 bytes */
......
...@@ -533,6 +533,7 @@ struct tc_cls_u32_offload; ...@@ -533,6 +533,7 @@ struct tc_cls_u32_offload;
struct tc_cbs_qopt_offload; struct tc_cbs_qopt_offload;
struct flow_cls_offload; struct flow_cls_offload;
struct tc_taprio_qopt_offload; struct tc_taprio_qopt_offload;
struct tc_etf_qopt_offload;
struct stmmac_tc_ops { struct stmmac_tc_ops {
int (*init)(struct stmmac_priv *priv); int (*init)(struct stmmac_priv *priv);
...@@ -544,6 +545,8 @@ struct stmmac_tc_ops { ...@@ -544,6 +545,8 @@ struct stmmac_tc_ops {
struct flow_cls_offload *cls); struct flow_cls_offload *cls);
int (*setup_taprio)(struct stmmac_priv *priv, int (*setup_taprio)(struct stmmac_priv *priv,
struct tc_taprio_qopt_offload *qopt); struct tc_taprio_qopt_offload *qopt);
int (*setup_etf)(struct stmmac_priv *priv,
struct tc_etf_qopt_offload *qopt);
}; };
#define stmmac_tc_init(__priv, __args...) \ #define stmmac_tc_init(__priv, __args...) \
...@@ -556,6 +559,8 @@ struct stmmac_tc_ops { ...@@ -556,6 +559,8 @@ struct stmmac_tc_ops {
stmmac_do_callback(__priv, tc, setup_cls, __args) stmmac_do_callback(__priv, tc, setup_cls, __args)
#define stmmac_tc_setup_taprio(__priv, __args...) \ #define stmmac_tc_setup_taprio(__priv, __args...) \
stmmac_do_callback(__priv, tc, setup_taprio, __args) stmmac_do_callback(__priv, tc, setup_taprio, __args)
#define stmmac_tc_setup_etf(__priv, __args...) \
stmmac_do_callback(__priv, tc, setup_etf, __args)
struct stmmac_counters; struct stmmac_counters;
......
...@@ -4159,6 +4159,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type, ...@@ -4159,6 +4159,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,
return stmmac_tc_setup_cbs(priv, priv, type_data); return stmmac_tc_setup_cbs(priv, priv, type_data);
case TC_SETUP_QDISC_TAPRIO: case TC_SETUP_QDISC_TAPRIO:
return stmmac_tc_setup_taprio(priv, priv, type_data); return stmmac_tc_setup_taprio(priv, priv, type_data);
case TC_SETUP_QDISC_ETF:
return stmmac_tc_setup_etf(priv, priv, type_data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -727,10 +727,31 @@ static int tc_setup_taprio(struct stmmac_priv *priv, ...@@ -727,10 +727,31 @@ static int tc_setup_taprio(struct stmmac_priv *priv,
return ret; return ret;
} }
static int tc_setup_etf(struct stmmac_priv *priv,
struct tc_etf_qopt_offload *qopt)
{
if (!priv->dma_cap.tbssel)
return -EOPNOTSUPP;
if (qopt->queue >= priv->plat->tx_queues_to_use)
return -EINVAL;
if (!(priv->tx_queue[qopt->queue].tbs & STMMAC_TBS_AVAIL))
return -EINVAL;
if (qopt->enable)
priv->tx_queue[qopt->queue].tbs |= STMMAC_TBS_EN;
else
priv->tx_queue[qopt->queue].tbs &= ~STMMAC_TBS_EN;
netdev_info(priv->dev, "%s ETF for Queue %d\n",
qopt->enable ? "enabled" : "disabled", qopt->queue);
return 0;
}
const struct stmmac_tc_ops dwmac510_tc_ops = { const struct stmmac_tc_ops dwmac510_tc_ops = {
.init = tc_init, .init = tc_init,
.setup_cls_u32 = tc_setup_cls_u32, .setup_cls_u32 = tc_setup_cls_u32,
.setup_cbs = tc_setup_cbs, .setup_cbs = tc_setup_cbs,
.setup_cls = tc_setup_cls, .setup_cls = tc_setup_cls,
.setup_taprio = tc_setup_taprio, .setup_taprio = tc_setup_taprio,
.setup_etf = tc_setup_etf,
}; };
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