aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudiu Manoil <claudiu.manoil@nxp.com>2016-11-16 09:40:30 -0500
committerScott Wood <oss@buserror.net>2016-11-23 22:01:25 -0500
commit18058822768f4665e2132ddd1cb413a9033edf09 (patch)
tree64f89bcf17829fab7540e4f493f075274faa3e85
parent496bfa11de2e6805b63168d45c2f92edbeae54e2 (diff)
soc/qman: Handle endianness of h/w descriptors
The hardware descriptors have big endian (BE) format. Provide proper endianness handling for the remaining descriptor fields, to ensure they are correctly accessed by non-BE CPUs too. Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Signed-off-by: Scott Wood <oss@buserror.net>
-rw-r--r--drivers/soc/fsl/qbman/qman.c65
-rw-r--r--drivers/soc/fsl/qbman/qman_priv.h10
-rw-r--r--drivers/soc/fsl/qbman/qman_test_api.c4
-rw-r--r--drivers/soc/fsl/qbman/qman_test_stash.c5
-rw-r--r--include/soc/fsl/qman.h48
5 files changed, 70 insertions, 62 deletions
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index acee99da71a7..6f509f68085e 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -140,10 +140,10 @@ enum qm_mr_cmode { /* matches QCSP_CFG::MM */
140struct qm_eqcr_entry { 140struct qm_eqcr_entry {
141 u8 _ncw_verb; /* writes to this are non-coherent */ 141 u8 _ncw_verb; /* writes to this are non-coherent */
142 u8 dca; 142 u8 dca;
143 u16 seqnum; 143 __be16 seqnum;
144 u8 __reserved[4]; 144 u8 __reserved[4];
145 u32 fqid; /* 24-bit */ 145 __be32 fqid; /* 24-bit */
146 u32 tag; 146 __be32 tag;
147 struct qm_fd fd; 147 struct qm_fd fd;
148 u8 __reserved3[32]; 148 u8 __reserved3[32];
149} __packed; 149} __packed;
@@ -187,7 +187,7 @@ struct qm_mr {
187struct qm_mcc_fq { 187struct qm_mcc_fq {
188 u8 _ncw_verb; 188 u8 _ncw_verb;
189 u8 __reserved1[3]; 189 u8 __reserved1[3];
190 u32 fqid; /* 24-bit */ 190 __be32 fqid; /* 24-bit */
191 u8 __reserved2[56]; 191 u8 __reserved2[56];
192} __packed; 192} __packed;
193 193
@@ -470,7 +470,7 @@ static inline struct qm_eqcr_entry *qm_eqcr_start_stash(struct qm_portal
470static inline void eqcr_commit_checks(struct qm_eqcr *eqcr) 470static inline void eqcr_commit_checks(struct qm_eqcr *eqcr)
471{ 471{
472 DPAA_ASSERT(eqcr->busy); 472 DPAA_ASSERT(eqcr->busy);
473 DPAA_ASSERT(!(eqcr->cursor->fqid & ~QM_FQID_MASK)); 473 DPAA_ASSERT(!(be32_to_cpu(eqcr->cursor->fqid) & ~QM_FQID_MASK));
474 DPAA_ASSERT(eqcr->available >= 1); 474 DPAA_ASSERT(eqcr->available >= 1);
475} 475}
476 476
@@ -1395,7 +1395,7 @@ static void qm_mr_process_task(struct work_struct *work)
1395 break; 1395 break;
1396 case QM_MR_VERB_FQPN: 1396 case QM_MR_VERB_FQPN:
1397 /* Parked */ 1397 /* Parked */
1398 fq = tag_to_fq(msg->fq.context_b); 1398 fq = tag_to_fq(be32_to_cpu(msg->fq.context_b));
1399 fq_state_change(p, fq, msg, verb); 1399 fq_state_change(p, fq, msg, verb);
1400 if (fq->cb.fqs) 1400 if (fq->cb.fqs)
1401 fq->cb.fqs(p, fq, msg); 1401 fq->cb.fqs(p, fq, msg);
@@ -1409,7 +1409,7 @@ static void qm_mr_process_task(struct work_struct *work)
1409 } 1409 }
1410 } else { 1410 } else {
1411 /* Its a software ERN */ 1411 /* Its a software ERN */
1412 fq = tag_to_fq(msg->ern.tag); 1412 fq = tag_to_fq(be32_to_cpu(msg->ern.tag));
1413 fq->cb.ern(p, fq, msg); 1413 fq->cb.ern(p, fq, msg);
1414 } 1414 }
1415 num++; 1415 num++;
@@ -1521,7 +1521,7 @@ static inline unsigned int __poll_portal_fast(struct qman_portal *p,
1521 clear_vdqcr(p, fq); 1521 clear_vdqcr(p, fq);
1522 } else { 1522 } else {
1523 /* SDQCR: context_b points to the FQ */ 1523 /* SDQCR: context_b points to the FQ */
1524 fq = tag_to_fq(dq->context_b); 1524 fq = tag_to_fq(be32_to_cpu(dq->context_b));
1525 /* Now let the callback do its stuff */ 1525 /* Now let the callback do its stuff */
1526 res = fq->cb.dqrr(p, fq, dq); 1526 res = fq->cb.dqrr(p, fq, dq);
1527 /* 1527 /*
@@ -1738,9 +1738,9 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts)
1738 if (fq_isset(fq, QMAN_FQ_FLAG_NO_MODIFY)) 1738 if (fq_isset(fq, QMAN_FQ_FLAG_NO_MODIFY))
1739 return -EINVAL; 1739 return -EINVAL;
1740#endif 1740#endif
1741 if (opts && (opts->we_mask & QM_INITFQ_WE_OAC)) { 1741 if (opts && (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_OAC)) {
1742 /* And can't be set at the same time as TDTHRESH */ 1742 /* And can't be set at the same time as TDTHRESH */
1743 if (opts->we_mask & QM_INITFQ_WE_TDTHRESH) 1743 if (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_TDTHRESH)
1744 return -EINVAL; 1744 return -EINVAL;
1745 } 1745 }
1746 /* Issue an INITFQ_[PARKED|SCHED] management command */ 1746 /* Issue an INITFQ_[PARKED|SCHED] management command */
@@ -1764,14 +1764,16 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts)
1764 if (fq_isclear(fq, QMAN_FQ_FLAG_TO_DCPORTAL)) { 1764 if (fq_isclear(fq, QMAN_FQ_FLAG_TO_DCPORTAL)) {
1765 dma_addr_t phys_fq; 1765 dma_addr_t phys_fq;
1766 1766
1767 mcc->initfq.we_mask |= QM_INITFQ_WE_CONTEXTB; 1767 mcc->initfq.we_mask |= cpu_to_be16(QM_INITFQ_WE_CONTEXTB);
1768 mcc->initfq.fqd.context_b = fq_to_tag(fq); 1768 mcc->initfq.fqd.context_b = cpu_to_be32(fq_to_tag(fq));
1769 /* 1769 /*
1770 * and the physical address - NB, if the user wasn't trying to 1770 * and the physical address - NB, if the user wasn't trying to
1771 * set CONTEXTA, clear the stashing settings. 1771 * set CONTEXTA, clear the stashing settings.
1772 */ 1772 */
1773 if (!(mcc->initfq.we_mask & QM_INITFQ_WE_CONTEXTA)) { 1773 if (!(be16_to_cpu(mcc->initfq.we_mask) &
1774 mcc->initfq.we_mask |= QM_INITFQ_WE_CONTEXTA; 1774 QM_INITFQ_WE_CONTEXTA)) {
1775 mcc->initfq.we_mask |=
1776 cpu_to_be16(QM_INITFQ_WE_CONTEXTA);
1775 memset(&mcc->initfq.fqd.context_a, 0, 1777 memset(&mcc->initfq.fqd.context_a, 0,
1776 sizeof(mcc->initfq.fqd.context_a)); 1778 sizeof(mcc->initfq.fqd.context_a));
1777 } else { 1779 } else {
@@ -1791,8 +1793,10 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts)
1791 if (flags & QMAN_INITFQ_FLAG_LOCAL) { 1793 if (flags & QMAN_INITFQ_FLAG_LOCAL) {
1792 int wq = 0; 1794 int wq = 0;
1793 1795
1794 if (!(mcc->initfq.we_mask & QM_INITFQ_WE_DESTWQ)) { 1796 if (!(be16_to_cpu(mcc->initfq.we_mask) &
1795 mcc->initfq.we_mask |= QM_INITFQ_WE_DESTWQ; 1797 QM_INITFQ_WE_DESTWQ)) {
1798 mcc->initfq.we_mask |=
1799 cpu_to_be16(QM_INITFQ_WE_DESTWQ);
1796 wq = 4; 1800 wq = 4;
1797 } 1801 }
1798 qm_fqd_set_destwq(&mcc->initfq.fqd, p->config->channel, wq); 1802 qm_fqd_set_destwq(&mcc->initfq.fqd, p->config->channel, wq);
@@ -1811,13 +1815,13 @@ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts)
1811 goto out; 1815 goto out;
1812 } 1816 }
1813 if (opts) { 1817 if (opts) {
1814 if (opts->we_mask & QM_INITFQ_WE_FQCTRL) { 1818 if (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_FQCTRL) {
1815 if (opts->fqd.fq_ctrl & QM_FQCTRL_CGE) 1819 if (be16_to_cpu(opts->fqd.fq_ctrl) & QM_FQCTRL_CGE)
1816 fq_set(fq, QMAN_FQ_STATE_CGR_EN); 1820 fq_set(fq, QMAN_FQ_STATE_CGR_EN);
1817 else 1821 else
1818 fq_clear(fq, QMAN_FQ_STATE_CGR_EN); 1822 fq_clear(fq, QMAN_FQ_STATE_CGR_EN);
1819 } 1823 }
1820 if (opts->we_mask & QM_INITFQ_WE_CGID) 1824 if (be16_to_cpu(opts->we_mask) & QM_INITFQ_WE_CGID)
1821 fq->cgr_groupid = opts->fqd.cgid; 1825 fq->cgr_groupid = opts->fqd.cgid;
1822 } 1826 }
1823 fq->state = (flags & QMAN_INITFQ_FLAG_SCHED) ? 1827 fq->state = (flags & QMAN_INITFQ_FLAG_SCHED) ?
@@ -1937,7 +1941,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
1937 msg.verb = QM_MR_VERB_FQRNI; 1941 msg.verb = QM_MR_VERB_FQRNI;
1938 msg.fq.fqs = mcr->alterfq.fqs; 1942 msg.fq.fqs = mcr->alterfq.fqs;
1939 qm_fqid_set(&msg.fq, fq->fqid); 1943 qm_fqid_set(&msg.fq, fq->fqid);
1940 msg.fq.context_b = fq_to_tag(fq); 1944 msg.fq.context_b = cpu_to_be32(fq_to_tag(fq));
1941 fq->cb.fqs(p, fq, &msg); 1945 fq->cb.fqs(p, fq, &msg);
1942 } 1946 }
1943 } else if (res == QM_MCR_RESULT_PENDING) { 1947 } else if (res == QM_MCR_RESULT_PENDING) {
@@ -2206,7 +2210,7 @@ int qman_enqueue(struct qman_fq *fq, const struct qm_fd *fd)
2206 goto out; 2210 goto out;
2207 2211
2208 qm_fqid_set(eq, fq->fqid); 2212 qm_fqid_set(eq, fq->fqid);
2209 eq->tag = fq_to_tag(fq); 2213 eq->tag = cpu_to_be32(fq_to_tag(fq));
2210 eq->fd = *fd; 2214 eq->fd = *fd;
2211 2215
2212 qm_eqcr_pvb_commit(&p->p, QM_EQCR_VERB_CMD_ENQUEUE); 2216 qm_eqcr_pvb_commit(&p->p, QM_EQCR_VERB_CMD_ENQUEUE);
@@ -2253,17 +2257,18 @@ out:
2253static void qm_cgr_cscn_targ_set(struct __qm_mc_cgr *cgr, int pi, u32 val) 2257static void qm_cgr_cscn_targ_set(struct __qm_mc_cgr *cgr, int pi, u32 val)
2254{ 2258{
2255 if (qman_ip_rev >= QMAN_REV30) 2259 if (qman_ip_rev >= QMAN_REV30)
2256 cgr->cscn_targ_upd_ctrl = QM_CGR_TARG_UDP_CTRL_WRITE_BIT | pi; 2260 cgr->cscn_targ_upd_ctrl = cpu_to_be16(pi |
2261 QM_CGR_TARG_UDP_CTRL_WRITE_BIT);
2257 else 2262 else
2258 cgr->cscn_targ = val | QM_CGR_TARG_PORTAL(pi); 2263 cgr->cscn_targ = cpu_to_be32(val | QM_CGR_TARG_PORTAL(pi));
2259} 2264}
2260 2265
2261static void qm_cgr_cscn_targ_clear(struct __qm_mc_cgr *cgr, int pi, u32 val) 2266static void qm_cgr_cscn_targ_clear(struct __qm_mc_cgr *cgr, int pi, u32 val)
2262{ 2267{
2263 if (qman_ip_rev >= QMAN_REV30) 2268 if (qman_ip_rev >= QMAN_REV30)
2264 cgr->cscn_targ_upd_ctrl = pi; 2269 cgr->cscn_targ_upd_ctrl = cpu_to_be16(pi);
2265 else 2270 else
2266 cgr->cscn_targ = val & ~QM_CGR_TARG_PORTAL(pi); 2271 cgr->cscn_targ = cpu_to_be32(val & ~QM_CGR_TARG_PORTAL(pi));
2267} 2272}
2268 2273
2269static u8 qman_cgr_cpus[CGR_NUM]; 2274static u8 qman_cgr_cpus[CGR_NUM];
@@ -2315,8 +2320,8 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
2315 goto out; 2320 goto out;
2316 2321
2317 qm_cgr_cscn_targ_set(&local_opts.cgr, PORTAL_IDX(p), 2322 qm_cgr_cscn_targ_set(&local_opts.cgr, PORTAL_IDX(p),
2318 cgr_state.cgr.cscn_targ); 2323 be32_to_cpu(cgr_state.cgr.cscn_targ));
2319 local_opts.we_mask |= QM_CGR_WE_CSCN_TARG; 2324 local_opts.we_mask |= cpu_to_be16(QM_CGR_WE_CSCN_TARG);
2320 2325
2321 /* send init if flags indicate so */ 2326 /* send init if flags indicate so */
2322 if (flags & QMAN_CGR_FLAG_USE_INIT) 2327 if (flags & QMAN_CGR_FLAG_USE_INIT)
@@ -2383,9 +2388,9 @@ int qman_delete_cgr(struct qman_cgr *cgr)
2383 goto release_lock; 2388 goto release_lock;
2384 } 2389 }
2385 2390
2386 local_opts.we_mask = QM_CGR_WE_CSCN_TARG; 2391 local_opts.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_TARG);
2387 qm_cgr_cscn_targ_clear(&local_opts.cgr, PORTAL_IDX(p), 2392 qm_cgr_cscn_targ_clear(&local_opts.cgr, PORTAL_IDX(p),
2388 cgr_state.cgr.cscn_targ); 2393 be32_to_cpu(cgr_state.cgr.cscn_targ));
2389 2394
2390 ret = qm_modify_cgr(cgr, 0, &local_opts); 2395 ret = qm_modify_cgr(cgr, 0, &local_opts);
2391 if (ret) 2396 if (ret)
@@ -2835,7 +2840,7 @@ static int cgr_cleanup(u32 cgrid)
2835 err = qman_query_fq(&fq, &fqd); 2840 err = qman_query_fq(&fq, &fqd);
2836 if (WARN_ON(err)) 2841 if (WARN_ON(err))
2837 return err; 2842 return err;
2838 if ((fqd.fq_ctrl & QM_FQCTRL_CGE) && 2843 if (be16_to_cpu(fqd.fq_ctrl) & QM_FQCTRL_CGE &&
2839 fqd.cgid == cgrid) { 2844 fqd.cgid == cgrid) {
2840 pr_err("CRGID 0x%x is being used by FQID 0x%x, CGR will be leaked\n", 2845 pr_err("CRGID 0x%x is being used by FQID 0x%x, CGR will be leaked\n",
2841 cgrid, fq.fqid); 2846 cgrid, fq.fqid);
diff --git a/drivers/soc/fsl/qbman/qman_priv.h b/drivers/soc/fsl/qbman/qman_priv.h
index 5606d74c21d4..53685b59718e 100644
--- a/drivers/soc/fsl/qbman/qman_priv.h
+++ b/drivers/soc/fsl/qbman/qman_priv.h
@@ -73,20 +73,20 @@ struct qm_mcr_querycgr {
73 struct __qm_mc_cgr cgr; /* CGR fields */ 73 struct __qm_mc_cgr cgr; /* CGR fields */
74 u8 __reserved2[6]; 74 u8 __reserved2[6];
75 u8 i_bcnt_hi; /* high 8-bits of 40-bit "Instant" */ 75 u8 i_bcnt_hi; /* high 8-bits of 40-bit "Instant" */
76 u32 i_bcnt_lo; /* low 32-bits of 40-bit */ 76 __be32 i_bcnt_lo; /* low 32-bits of 40-bit */
77 u8 __reserved3[3]; 77 u8 __reserved3[3];
78 u8 a_bcnt_hi; /* high 8-bits of 40-bit "Average" */ 78 u8 a_bcnt_hi; /* high 8-bits of 40-bit "Average" */
79 u32 a_bcnt_lo; /* low 32-bits of 40-bit */ 79 __be32 a_bcnt_lo; /* low 32-bits of 40-bit */
80 u32 cscn_targ_swp[4]; 80 __be32 cscn_targ_swp[4];
81} __packed; 81} __packed;
82 82
83static inline u64 qm_mcr_querycgr_i_get64(const struct qm_mcr_querycgr *q) 83static inline u64 qm_mcr_querycgr_i_get64(const struct qm_mcr_querycgr *q)
84{ 84{
85 return ((u64)q->i_bcnt_hi << 32) | (u64)q->i_bcnt_lo; 85 return ((u64)q->i_bcnt_hi << 32) | be32_to_cpu(q->i_bcnt_lo);
86} 86}
87static inline u64 qm_mcr_querycgr_a_get64(const struct qm_mcr_querycgr *q) 87static inline u64 qm_mcr_querycgr_a_get64(const struct qm_mcr_querycgr *q)
88{ 88{
89 return ((u64)q->a_bcnt_hi << 32) | (u64)q->a_bcnt_lo; 89 return ((u64)q->a_bcnt_hi << 32) | be32_to_cpu(q->a_bcnt_lo);
90} 90}
91 91
92/* "Query FQ Non-Programmable Fields" */ 92/* "Query FQ Non-Programmable Fields" */
diff --git a/drivers/soc/fsl/qbman/qman_test_api.c b/drivers/soc/fsl/qbman/qman_test_api.c
index dba6a80622ed..2895d062cf51 100644
--- a/drivers/soc/fsl/qbman/qman_test_api.c
+++ b/drivers/soc/fsl/qbman/qman_test_api.c
@@ -65,7 +65,7 @@ static void fd_init(struct qm_fd *fd)
65{ 65{
66 qm_fd_addr_set64(fd, 0xabdeadbeefLLU); 66 qm_fd_addr_set64(fd, 0xabdeadbeefLLU);
67 qm_fd_set_contig_big(fd, 0x0000ffff); 67 qm_fd_set_contig_big(fd, 0x0000ffff);
68 fd->cmd = 0xfeedf00d; 68 fd->cmd = cpu_to_be32(0xfeedf00d);
69} 69}
70 70
71static void fd_inc(struct qm_fd *fd) 71static void fd_inc(struct qm_fd *fd)
@@ -86,7 +86,7 @@ static void fd_inc(struct qm_fd *fd)
86 len--; 86 len--;
87 qm_fd_set_param(fd, fmt, off, len); 87 qm_fd_set_param(fd, fmt, off, len);
88 88
89 fd->cmd++; 89 fd->cmd = cpu_to_be32(be32_to_cpu(fd->cmd) + 1);
90} 90}
91 91
92/* The only part of the 'fd' we can't memcmp() is the ppid */ 92/* The only part of the 'fd' we can't memcmp() is the ppid */
diff --git a/drivers/soc/fsl/qbman/qman_test_stash.c b/drivers/soc/fsl/qbman/qman_test_stash.c
index f8d25faf4d8a..b9795f39bcc8 100644
--- a/drivers/soc/fsl/qbman/qman_test_stash.c
+++ b/drivers/soc/fsl/qbman/qman_test_stash.c
@@ -406,8 +406,9 @@ static int init_handler(void *h)
406 goto failed; 406 goto failed;
407 } 407 }
408 memset(&opts, 0, sizeof(opts)); 408 memset(&opts, 0, sizeof(opts));
409 opts.we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA; 409 opts.we_mask = cpu_to_be16(QM_INITFQ_WE_FQCTRL |
410 opts.fqd.fq_ctrl = QM_FQCTRL_CTXASTASHING; 410 QM_INITFQ_WE_CONTEXTA);
411 opts.fqd.fq_ctrl = cpu_to_be16(QM_FQCTRL_CTXASTASHING);
411 qm_fqd_set_stashing(&opts.fqd, 0, STASH_DATA_CL, STASH_CTX_CL); 412 qm_fqd_set_stashing(&opts.fqd, 0, STASH_DATA_CL, STASH_CTX_CL);
412 err = qman_init_fq(&handler->rx, QMAN_INITFQ_FLAG_SCHED | 413 err = qman_init_fq(&handler->rx, QMAN_INITFQ_FLAG_SCHED |
413 QMAN_INITFQ_FLAG_LOCAL, &opts); 414 QMAN_INITFQ_FLAG_LOCAL, &opts);
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index d01d5a358945..3d4df74a96de 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -244,11 +244,11 @@ static inline int qm_sg_entry_get_off(const struct qm_sg_entry *sg)
244struct qm_dqrr_entry { 244struct qm_dqrr_entry {
245 u8 verb; 245 u8 verb;
246 u8 stat; 246 u8 stat;
247 u16 seqnum; /* 15-bit */ 247 __be16 seqnum; /* 15-bit */
248 u8 tok; 248 u8 tok;
249 u8 __reserved2[3]; 249 u8 __reserved2[3];
250 u32 fqid; /* 24-bit */ 250 __be32 fqid; /* 24-bit */
251 u32 context_b; 251 __be32 context_b;
252 struct qm_fd fd; 252 struct qm_fd fd;
253 u8 __reserved4[32]; 253 u8 __reserved4[32];
254} __packed; 254} __packed;
@@ -264,8 +264,8 @@ struct qm_dqrr_entry {
264 264
265/* 'fqid' is a 24-bit field in every h/w descriptor */ 265/* 'fqid' is a 24-bit field in every h/w descriptor */
266#define QM_FQID_MASK GENMASK(23, 0) 266#define QM_FQID_MASK GENMASK(23, 0)
267#define qm_fqid_set(p, v) ((p)->fqid = ((v) & QM_FQID_MASK)) 267#define qm_fqid_set(p, v) ((p)->fqid = cpu_to_be32((v) & QM_FQID_MASK))
268#define qm_fqid_get(p) ((p)->fqid & QM_FQID_MASK) 268#define qm_fqid_get(p) (be32_to_cpu((p)->fqid) & QM_FQID_MASK)
269 269
270/* "ERN Message Response" */ 270/* "ERN Message Response" */
271/* "FQ State Change Notification" */ 271/* "FQ State Change Notification" */
@@ -277,11 +277,11 @@ union qm_mr_entry {
277 struct { 277 struct {
278 u8 verb; 278 u8 verb;
279 u8 dca; 279 u8 dca;
280 u16 seqnum; 280 __be16 seqnum;
281 u8 rc; /* Rej Code: 8-bit */ 281 u8 rc; /* Rej Code: 8-bit */
282 u8 __reserved[3]; 282 u8 __reserved[3];
283 u32 fqid; /* 24-bit */ 283 __be32 fqid; /* 24-bit */
284 u32 tag; 284 __be32 tag;
285 struct qm_fd fd; 285 struct qm_fd fd;
286 u8 __reserved1[32]; 286 u8 __reserved1[32];
287 } __packed ern; 287 } __packed ern;
@@ -289,8 +289,8 @@ union qm_mr_entry {
289 u8 verb; 289 u8 verb;
290 u8 fqs; /* Frame Queue Status */ 290 u8 fqs; /* Frame Queue Status */
291 u8 __reserved1[6]; 291 u8 __reserved1[6];
292 u32 fqid; /* 24-bit */ 292 __be32 fqid; /* 24-bit */
293 u32 context_b; 293 __be32 context_b;
294 u8 __reserved2[48]; 294 u8 __reserved2[48];
295 } __packed fq; /* FQRN/FQRNI/FQRL/FQPN */ 295 } __packed fq; /* FQRN/FQRNI/FQRL/FQPN */
296}; 296};
@@ -409,8 +409,8 @@ static inline u64 qm_fqd_context_a_get64(const struct qm_fqd *fqd)
409 409
410static inline void qm_fqd_stashing_set64(struct qm_fqd *fqd, u64 addr) 410static inline void qm_fqd_stashing_set64(struct qm_fqd *fqd, u64 addr)
411{ 411{
412 fqd->context_a.context_hi = upper_32_bits(addr); 412 fqd->context_a.context_hi = cpu_to_be16(upper_32_bits(addr));
413 fqd->context_a.context_lo = lower_32_bits(addr); 413 fqd->context_a.context_lo = cpu_to_be32(lower_32_bits(addr));
414} 414}
415 415
416static inline void qm_fqd_context_a_set64(struct qm_fqd *fqd, u64 addr) 416static inline void qm_fqd_context_a_set64(struct qm_fqd *fqd, u64 addr)
@@ -525,7 +525,7 @@ static inline int qm_fqd_get_wq(const struct qm_fqd *fqd)
525 */ 525 */
526struct qm_cgr_wr_parm { 526struct qm_cgr_wr_parm {
527 /* MA[24-31], Mn[19-23], SA[12-18], Sn[6-11], Pn[0-5] */ 527 /* MA[24-31], Mn[19-23], SA[12-18], Sn[6-11], Pn[0-5] */
528 u32 word; 528 __be32 word;
529}; 529};
530/* 530/*
531 * This struct represents the 13-bit "CS_THRES" CGR field. In the corresponding 531 * This struct represents the 13-bit "CS_THRES" CGR field. In the corresponding
@@ -536,7 +536,7 @@ struct qm_cgr_wr_parm {
536 */ 536 */
537struct qm_cgr_cs_thres { 537struct qm_cgr_cs_thres {
538 /* _res[13-15], TA[5-12], Tn[0-4] */ 538 /* _res[13-15], TA[5-12], Tn[0-4] */
539 u16 word; 539 __be16 word;
540}; 540};
541/* 541/*
542 * This identical structure of CGR fields is present in the "Init/Modify CGR" 542 * This identical structure of CGR fields is present in the "Init/Modify CGR"
@@ -553,10 +553,10 @@ struct __qm_mc_cgr {
553 u8 cscn_en; /* boolean, use QM_CGR_EN */ 553 u8 cscn_en; /* boolean, use QM_CGR_EN */
554 union { 554 union {
555 struct { 555 struct {
556 u16 cscn_targ_upd_ctrl; /* use QM_CGR_TARG_UDP_* */ 556 __be16 cscn_targ_upd_ctrl; /* use QM_CGR_TARG_UDP_* */
557 u16 cscn_targ_dcp_low; 557 __be16 cscn_targ_dcp_low;
558 }; 558 };
559 u32 cscn_targ; /* use QM_CGR_TARG_* */ 559 __be32 cscn_targ; /* use QM_CGR_TARG_* */
560 }; 560 };
561 u8 cstd_en; /* boolean, use QM_CGR_EN */ 561 u8 cstd_en; /* boolean, use QM_CGR_EN */
562 u8 cs; /* boolean, only used in query response */ 562 u8 cs; /* boolean, only used in query response */
@@ -572,7 +572,9 @@ struct __qm_mc_cgr {
572/* Convert CGR thresholds to/from "cs_thres" format */ 572/* Convert CGR thresholds to/from "cs_thres" format */
573static inline u64 qm_cgr_cs_thres_get64(const struct qm_cgr_cs_thres *th) 573static inline u64 qm_cgr_cs_thres_get64(const struct qm_cgr_cs_thres *th)
574{ 574{
575 return ((th->word >> 5) & 0xff) << (th->word & 0x1f); 575 int thres = be16_to_cpu(th->word);
576
577 return ((thres >> 5) & 0xff) << (thres & 0x1f);
576} 578}
577 579
578static inline int qm_cgr_cs_thres_set64(struct qm_cgr_cs_thres *th, u64 val, 580static inline int qm_cgr_cs_thres_set64(struct qm_cgr_cs_thres *th, u64 val,
@@ -588,23 +590,23 @@ static inline int qm_cgr_cs_thres_set64(struct qm_cgr_cs_thres *th, u64 val,
588 if (roundup && oddbit) 590 if (roundup && oddbit)
589 val++; 591 val++;
590 } 592 }
591 th->word = ((val & 0xff) << 5) | (e & 0x1f); 593 th->word = cpu_to_be16(((val & 0xff) << 5) | (e & 0x1f));
592 return 0; 594 return 0;
593} 595}
594 596
595/* "Initialize FQ" */ 597/* "Initialize FQ" */
596struct qm_mcc_initfq { 598struct qm_mcc_initfq {
597 u8 __reserved1[2]; 599 u8 __reserved1[2];
598 u16 we_mask; /* Write Enable Mask */ 600 __be16 we_mask; /* Write Enable Mask */
599 u32 fqid; /* 24-bit */ 601 __be32 fqid; /* 24-bit */
600 u16 count; /* Initialises 'count+1' FQDs */ 602 __be16 count; /* Initialises 'count+1' FQDs */
601 struct qm_fqd fqd; /* the FQD fields go here */ 603 struct qm_fqd fqd; /* the FQD fields go here */
602 u8 __reserved2[30]; 604 u8 __reserved2[30];
603} __packed; 605} __packed;
604/* "Initialize/Modify CGR" */ 606/* "Initialize/Modify CGR" */
605struct qm_mcc_initcgr { 607struct qm_mcc_initcgr {
606 u8 __reserve1[2]; 608 u8 __reserve1[2];
607 u16 we_mask; /* Write Enable Mask */ 609 __be16 we_mask; /* Write Enable Mask */
608 struct __qm_mc_cgr cgr; /* CGR fields */ 610 struct __qm_mc_cgr cgr; /* CGR fields */
609 u8 __reserved2[2]; 611 u8 __reserved2[2];
610 u8 cgid; 612 u8 cgid;