linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Claudiu Manoil <claudiu.manoil@nxp.com>
To: <linuxppc-dev@lists.ozlabs.org>
Cc: Scott Wood <oss@buserror.net>, <roy.pledge@nxp.com>
Subject: [PATCH 16/17] soc/qman: Clean up CGR CSCN target update operations
Date: Wed, 16 Nov 2016 16:40:29 +0200	[thread overview]
Message-ID: <1479307230-16650-17-git-send-email-claudiu.manoil@nxp.com> (raw)
In-Reply-To: <1479307230-16650-1-git-send-email-claudiu.manoil@nxp.com>

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/soc/fsl/qbman/qman.c | 37 +++++++++++++++++++++++--------------
 include/soc/fsl/qman.h       |  4 ++--
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ac020fd..d287ef0 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2248,7 +2248,23 @@ static int qm_modify_cgr(struct qman_cgr *cgr, u32 flags,
 }
 
 #define PORTAL_IDX(n)	(n->config->channel - QM_CHANNEL_SWPORTAL0)
-#define TARG_MASK(n)	(BIT(31) >> PORTAL_IDX(n))
+
+/* congestion state change notification target update control */
+static void qm_cgr_cscn_targ_set(struct __qm_mc_cgr *cgr, int pi, u32 val)
+{
+	if (qman_ip_rev >= QMAN_REV30)
+		cgr->cscn_targ_upd_ctrl = QM_CGR_TARG_UDP_CTRL_WRITE_BIT | pi;
+	else
+		cgr->cscn_targ = val | QM_CGR_TARG_PORTAL(pi);
+}
+
+static void qm_cgr_cscn_targ_clear(struct __qm_mc_cgr *cgr, int pi, u32 val)
+{
+	if (qman_ip_rev >= QMAN_REV30)
+		cgr->cscn_targ_upd_ctrl = pi;
+	else
+		cgr->cscn_targ = val & ~QM_CGR_TARG_PORTAL(pi);
+}
 
 static u8 qman_cgr_cpus[CGR_NUM];
 
@@ -2298,13 +2314,8 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 		if (ret)
 			goto out;
 
-		if ((qman_ip_rev & 0xFF00) >= QMAN_REV30)
-			local_opts.cgr.cscn_targ_upd_ctrl =
-				QM_CGR_TARG_UDP_CTRL_WRITE_BIT | PORTAL_IDX(p);
-		else
-			/* Overwrite TARG */
-			local_opts.cgr.cscn_targ = cgr_state.cgr.cscn_targ |
-						   TARG_MASK(p);
+		qm_cgr_cscn_targ_set(&local_opts.cgr, PORTAL_IDX(p),
+				     cgr_state.cgr.cscn_targ);
 		local_opts.we_mask |= QM_CGR_WE_CSCN_TARG;
 
 		/* send init if flags indicate so */
@@ -2371,13 +2382,11 @@ int qman_delete_cgr(struct qman_cgr *cgr)
 		list_add(&cgr->node, &p->cgr_cbs);
 		goto release_lock;
 	}
-	/* Overwrite TARG */
+
 	local_opts.we_mask = QM_CGR_WE_CSCN_TARG;
-	if ((qman_ip_rev & 0xFF00) >= QMAN_REV30)
-		local_opts.cgr.cscn_targ_upd_ctrl = PORTAL_IDX(p);
-	else
-		local_opts.cgr.cscn_targ = cgr_state.cgr.cscn_targ &
-							 ~(TARG_MASK(p));
+	qm_cgr_cscn_targ_clear(&local_opts.cgr, PORTAL_IDX(p),
+			       cgr_state.cgr.cscn_targ);
+
 	ret = qm_modify_cgr(cgr, 0, &local_opts);
 	if (ret)
 		/* add back to the list */
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index c80ecca..d01d5a3 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -553,8 +553,8 @@ struct __qm_mc_cgr {
 	u8 cscn_en;	/* boolean, use QM_CGR_EN */
 	union {
 		struct {
-			u16 cscn_targ_upd_ctrl; /* use QM_CSCN_TARG_UDP_ */
-			u16 cscn_targ_dcp_low;	/* CSCN_TARG_DCP low-16bits */
+			u16 cscn_targ_upd_ctrl; /* use QM_CGR_TARG_UDP_* */
+			u16 cscn_targ_dcp_low;
 		};
 		u32 cscn_targ;	/* use QM_CGR_TARG_* */
 	};
-- 
1.7.11.7

  parent reply	other threads:[~2016-11-16 14:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 14:40 [PATCH 00/17] soc/qman: Fixes, endianness handling and related cleanup Claudiu Manoil
2016-11-16 14:40 ` [PATCH 01/17] soc/qman: Check ioremap return value Claudiu Manoil
2016-11-16 14:40 ` [PATCH 02/17] soc/qman: Replace of_get_property() with portable equivalent Claudiu Manoil
2016-11-16 14:40 ` [PATCH 03/17] soc/qman: Fix h/w resource cleanup error path handling Claudiu Manoil
2016-11-16 14:40 ` [PATCH 04/17] soc/qbman: Fix resource leak on portal probing error path Claudiu Manoil
2016-11-16 14:40 ` [PATCH 05/17] soc/qman: Fix struct qm_fqd set accessor for context_a Claudiu Manoil
2016-11-16 14:40 ` [PATCH 06/17] soc/qman: Fix direct access to fd's addr_lo, use proper accesor Claudiu Manoil
2016-11-16 14:40 ` [PATCH 07/17] soc/qman: test: Fix implementation of fd_cmp() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 08/17] soc/qman: Don't add a new platform device for dma mapping Claudiu Manoil
2016-11-16 14:40 ` [PATCH 09/17] soc/qman: test: Don't use dummy " Claudiu Manoil
2016-11-16 14:40 ` [PATCH 10/17] soc/qman: Remove redundant checks from qman_create_cgr() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 11/17] soc/qman: Remove unused struct qm_mcc* layouts Claudiu Manoil
2016-11-16 14:40 ` [PATCH 12/17] soc/qman: Fix accesses to fqid, cleanup Claudiu Manoil
2016-11-16 14:40 ` [PATCH 13/17] soc/qman: Drop unused field from eqcr/dqrr descriptors Claudiu Manoil
2016-11-16 14:40 ` [PATCH 14/17] soc/qbman: Handle endianness of qm/bm_in/out() Claudiu Manoil
2016-11-16 14:40 ` [PATCH 15/17] soc/qman: Change remaining contextB into context_b Claudiu Manoil
2016-11-16 14:40 ` Claudiu Manoil [this message]
2016-11-16 14:40 ` [PATCH 17/17] soc/qman: Handle endianness of h/w descriptors Claudiu Manoil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479307230-16650-17-git-send-email-claudiu.manoil@nxp.com \
    --to=claudiu.manoil@nxp.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oss@buserror.net \
    --cc=roy.pledge@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).