soc/qman: Clean up CGR CSCN target update operations
authorClaudiu Manoil <claudiu.manoil@nxp.com>
Wed, 16 Nov 2016 14:40:29 +0000 (16:40 +0200)
committerScott Wood <oss@buserror.net>
Wed, 23 Nov 2016 07:23:49 +0000 (01:23 -0600)
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Scott Wood <oss@buserror.net>
drivers/soc/fsl/qbman/qman.c
include/soc/fsl/qman.h

index 8386acc1d37d2ed8aa5d2a3368ab42fe02c0c5df..acee99da71a78b5ce2245ff79ad68d24d8d1fab5 100644 (file)
@@ -2248,7 +2248,23 @@ out:
 }
 
 #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 */
index c80eccac64f6ca06413ccf3bfdad9e37eb72cb9f..d01d5a358945726724be4928099160ad662d6419 100644 (file)
@@ -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_* */
        };