-/*-
- * BSD LICENSE
+/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
+ * Copyright 2018-2020 NXP
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "qbman_private.h"
+#ifndef _QBMAN_PORTAL_H_
+#define _QBMAN_PORTAL_H_
+
+#include "qbman_sys.h"
#include <fsl_qbman_portal.h>
+extern uint32_t qman_version;
+#define QMAN_REV_4000 0x04000000
+#define QMAN_REV_4100 0x04010000
+#define QMAN_REV_4101 0x04010001
+
/* All QBMan command and result structures use this "valid bit" encoding */
#define QB_VALID_BIT ((uint32_t)0x80)
+/* All QBMan command use this "Read trigger bit" encoding */
+#define QB_RT_BIT ((uint32_t)0x100)
+
/* Management command result codes */
#define QBMAN_MC_RSLT_OK 0xf0
/* QBMan DQRR size is set at runtime in qbman_portal.c */
-#define QBMAN_EQCR_SIZE 8
-
-static inline u8 qm_cyc_diff(u8 ringsize, u8 first, u8 last)
+static inline uint8_t qm_cyc_diff(uint8_t ringsize, uint8_t first,
+ uint8_t last)
{
/* 'first' is included, 'last' is excluded */
if (first <= last)
#endif
uint32_t valid_bit; /* 0x00 or 0x80 */
} mc;
+ /* Management response */
+ struct {
+ uint32_t valid_bit; /* 0x00 or 0x80 */
+ } mr;
/* Push dequeues */
uint32_t sdq;
/* Volatile dequeues */
struct {
uint32_t pi;
uint32_t pi_vb;
+ uint32_t pi_ring_size;
+ uint32_t pi_ci_mask;
uint32_t ci;
int available;
} eqcr;
+ uint8_t stash_off;
};
/* -------------------------- */
* non-NULL if only if the response is complete).
*/
void *qbman_swp_mc_start(struct qbman_swp *p);
-void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb);
+void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint8_t cmd_verb);
+void qbman_swp_mc_submit_cinh(struct qbman_swp *p, void *cmd, uint8_t cmd_verb);
void *qbman_swp_mc_result(struct qbman_swp *p);
+void *qbman_swp_mc_result_cinh(struct qbman_swp *p);
/* Wraps up submit + poll-for-result */
static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd,
- uint32_t cmd_verb)
+ uint8_t cmd_verb)
{
- int loopvar;
+ int loopvar = 1000;
qbman_swp_mc_submit(swp, cmd, cmd_verb);
- DBG_POLL_START(loopvar);
do {
- DBG_POLL_CHECK(loopvar);
cmd = qbman_swp_mc_result(swp);
- } while (!cmd);
- return cmd;
-}
+ } while (!cmd && loopvar--);
+ QBMAN_BUG_ON(!loopvar);
-/* ------------ */
-/* qb_attr_code */
-/* ------------ */
-
-/* This struct locates a sub-field within a QBMan portal (CENA) cacheline which
- * is either serving as a configuration command or a query result. The
- * representation is inherently little-endian, as the indexing of the words is
- * itself little-endian in nature and DPAA2 QBMan is little endian for anything
- * that crosses a word boundary too (64-bit fields are the obvious examples).
- */
-struct qb_attr_code {
- unsigned int word; /* which uint32_t[] array member encodes the field */
- unsigned int lsoffset; /* encoding offset from ls-bit */
- unsigned int width; /* encoding width. (bool must be 1.) */
-};
-
-/* Some pre-defined codes */
-extern struct qb_attr_code code_generic_verb;
-extern struct qb_attr_code code_generic_rslt;
-
-/* Macros to define codes */
-#define QB_CODE(a, b, c) { a, b, c}
-#define QB_CODE_NULL \
- QB_CODE((unsigned int)-1, (unsigned int)-1, (unsigned int)-1)
-
-/* Rotate a code "ms", meaning that it moves from less-significant bytes to
- * more-significant, from less-significant words to more-significant, etc. The
- * "ls" version does the inverse, from more-significant towards
- * less-significant.
- */
-static inline void qb_attr_code_rotate_ms(struct qb_attr_code *code,
- unsigned int bits)
-{
- code->lsoffset += bits;
- while (code->lsoffset > 31) {
- code->word++;
- code->lsoffset -= 32;
- }
-}
-
-static inline void qb_attr_code_rotate_ls(struct qb_attr_code *code,
- unsigned int bits)
-{
- /* Don't be fooled, this trick should work because the types are
- * unsigned. So the case that interests the while loop (the rotate has
- * gone too far and the word count needs to compensate for it), is
- * manifested when lsoffset is negative. But that equates to a really
- * large unsigned value, starting with lots of "F"s. As such, we can
- * continue adding 32 back to it until it wraps back round above zero,
- * to a value of 31 or less...
- */
- code->lsoffset -= bits;
- while (code->lsoffset > 31) {
- code->word--;
- code->lsoffset += 32;
- }
-}
-
-/* Implement a loop of code rotations until 'expr' evaluates to FALSE (0). */
-#define qb_attr_code_for_ms(code, bits, expr) \
- for (; expr; qb_attr_code_rotate_ms(code, bits))
-#define qb_attr_code_for_ls(code, bits, expr) \
- for (; expr; qb_attr_code_rotate_ls(code, bits))
-
-/* decode a field from a cacheline */
-static inline uint32_t qb_attr_code_decode(const struct qb_attr_code *code,
- const uint32_t *cacheline)
-{
- return d32_uint32_t(code->lsoffset, code->width, cacheline[code->word]);
-}
-
-static inline uint64_t qb_attr_code_decode_64(const struct qb_attr_code *code,
- const uint64_t *cacheline)
-{
- return cacheline[code->word / 2];
+ return cmd;
}
-/* encode a field to a cacheline */
-static inline void qb_attr_code_encode(const struct qb_attr_code *code,
- uint32_t *cacheline, uint32_t val)
+static inline void *qbman_swp_mc_complete_cinh(struct qbman_swp *swp, void *cmd,
+ uint8_t cmd_verb)
{
- cacheline[code->word] =
- r32_uint32_t(code->lsoffset, code->width, cacheline[code->word])
- | e32_uint32_t(code->lsoffset, code->width, val);
-}
+ int loopvar = 1000;
-static inline void qb_attr_code_encode_64(const struct qb_attr_code *code,
- uint64_t *cacheline, uint64_t val)
-{
- cacheline[code->word / 2] = val;
-}
+ qbman_swp_mc_submit_cinh(swp, cmd, cmd_verb);
+ do {
+ cmd = qbman_swp_mc_result_cinh(swp);
+ } while (!cmd && loopvar--);
+ QBMAN_BUG_ON(!loopvar);
-/* Small-width signed values (two's-complement) will decode into medium-width
- * positives. (Eg. for an 8-bit signed field, which stores values from -128 to
- * +127, a setting of -7 would appear to decode to the 32-bit unsigned value
- * 249. Likewise -120 would decode as 136.) This function allows the caller to
- * "re-sign" such fields to 32-bit signed. (Eg. -7, which was 249 with an 8-bit
- * encoding, will become 0xfffffff9 if you cast the return value to uint32_t).
- */
-static inline int32_t qb_attr_code_makesigned(const struct qb_attr_code *code,
- uint32_t val)
-{
- QBMAN_BUG_ON(val >= (1u << code->width));
- /* code->width should never exceed the width of val. If it does then a
- * different function with larger val size must be used to translate
- * from unsigned to signed
- */
- QBMAN_BUG_ON(code->width > sizeof(val) * CHAR_BIT);
- /* If the high bit was set, it was encoding a negative */
- if (val >= 1u << (code->width - 1))
- return (int32_t)0 - (int32_t)(((uint32_t)1 << code->width) -
- val);
- /* Otherwise, it was encoding a positive */
- return (int32_t)val;
+ return cmd;
}
/* ---------------------- */
* correctly with const and non-const inputs (and similarly-qualified outputs).
*/
#define qb_cl(d) (&(d)->dont_manipulate_directly[0])
+
+#ifdef RTE_ARCH_ARM64
+ #define clean(p) \
+ { asm volatile("dc cvac, %0;" : : "r" (p) : "memory"); }
+ #define invalidate(p) \
+ { asm volatile("dc ivac, %0" : : "r"(p) : "memory"); }
+#else
+ #define clean(p)
+ #define invalidate(p)
+#endif
+
+#endif