1 From fe7ed61721646077de5eb06a105e60634374a00c Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Thu, 31 May 2018 10:45:50 +0300
4 Subject: [PATCH] sdk_dpaa: ceetm: drain the ceetm CQs on destroy
6 The CEETM CQs must be empty when configured. To guarantee this, stop all
7 transmissions and wait for them to drain before releasing them. On the
8 next configuration, we are certain they will be empty.
10 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
12 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 62 ++++++++++++++++++++++
13 1 file changed, 62 insertions(+)
15 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
16 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
17 @@ -90,6 +90,51 @@ static void dpaa_drain_fqs(struct net_de
21 +/* Wait for the DPAA CEETM TX CQs to empty */
22 +static void ceetm_drain_class(struct ceetm_class *cl)
24 + struct qm_mcr_ceetm_cq_query cq_query;
25 + struct qm_ceetm_cq *cq;
34 + /* The ROOT classes aren't directly linked to CEETM CQs */
37 + cq = (struct qm_ceetm_cq*)cl->prio.cq;
40 + cq = (struct qm_ceetm_cq*)cl->wbfs.cq;
47 + /* Build the query CQID by merging the channel and the CQ IDs */
48 + idx = (cq->parent->idx << 4) | cq->idx;
51 + ret = qman_ceetm_query_cq(idx,
54 + if (unlikely(ret)) {
55 + pr_err(KBUILD_BASENAME
56 + " : %s : unable to query CQ %x: %d\n",
57 + __func__, idx, ret);
61 + if (cq_query.frm_cnt == 0)
66 /* Enqueue Rejection Notification callback */
67 static void ceetm_ern(struct qman_portal *portal, struct qman_fq *fq,
68 const struct qm_mr_entry *msg)
69 @@ -376,6 +421,8 @@ static void ceetm_link_class(struct Qdis
70 /* Destroy a ceetm class */
71 static void ceetm_cls_destroy(struct Qdisc *sch, struct ceetm_class *cl)
73 + struct net_device *dev = qdisc_dev(sch);
78 @@ -402,6 +449,12 @@ static void ceetm_cls_destroy(struct Qdi
79 cl->prio.child = NULL;
82 + /* We must make sure the CQ is empty before releasing it.
83 + * Pause all transmissions while we wait for it to drain.
85 + netif_tx_stop_all_queues(dev);
86 + ceetm_drain_class(cl);
88 if (cl->prio.lfq && qman_ceetm_lfq_release(cl->prio.lfq))
89 pr_err(KBUILD_BASENAME
90 " : %s : error releasing the LFQ %d\n",
91 @@ -422,9 +475,16 @@ static void ceetm_cls_destroy(struct Qdi
93 free_percpu(cl->prio.cstats);
95 + netif_tx_wake_all_queues(dev);
99 + /* We must make sure the CQ is empty before releasing it.
100 + * Pause all transmissions while we wait for it to drain.
102 + netif_tx_stop_all_queues(dev);
103 + ceetm_drain_class(cl);
105 if (cl->wbfs.lfq && qman_ceetm_lfq_release(cl->wbfs.lfq))
106 pr_err(KBUILD_BASENAME
107 " : %s : error releasing the LFQ %d\n",
108 @@ -444,6 +504,8 @@ static void ceetm_cls_destroy(struct Qdi
111 free_percpu(cl->wbfs.cstats);
113 + netif_tx_wake_all_queues(dev);
116 tcf_block_put(cl->block);