cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dpaa2-global.h (4291B)


      1/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
      2/*
      3 * Copyright 2014-2016 Freescale Semiconductor Inc.
      4 * Copyright 2016 NXP
      5 *
      6 */
      7#ifndef __FSL_DPAA2_GLOBAL_H
      8#define __FSL_DPAA2_GLOBAL_H
      9
     10#include <linux/types.h>
     11#include <linux/cpumask.h>
     12#include "dpaa2-fd.h"
     13
     14struct dpaa2_dq {
     15	union {
     16		struct common {
     17			u8 verb;
     18			u8 reserved[63];
     19		} common;
     20		struct dq {
     21			u8 verb;
     22			u8 stat;
     23			__le16 seqnum;
     24			__le16 oprid;
     25			u8 reserved;
     26			u8 tok;
     27			__le32 fqid;
     28			u32 reserved2;
     29			__le32 fq_byte_cnt;
     30			__le32 fq_frm_cnt;
     31			__le64 fqd_ctx;
     32			u8 fd[32];
     33		} dq;
     34		struct scn {
     35			u8 verb;
     36			u8 stat;
     37			u8 state;
     38			u8 reserved;
     39			__le32 rid_tok;
     40			__le64 ctx;
     41		} scn;
     42	};
     43};
     44
     45/* Parsing frame dequeue results */
     46/* FQ empty */
     47#define DPAA2_DQ_STAT_FQEMPTY       0x80
     48/* FQ held active */
     49#define DPAA2_DQ_STAT_HELDACTIVE    0x40
     50/* FQ force eligible */
     51#define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
     52/* valid frame */
     53#define DPAA2_DQ_STAT_VALIDFRAME    0x10
     54/* FQ ODP enable */
     55#define DPAA2_DQ_STAT_ODPVALID      0x04
     56/* volatile dequeue */
     57#define DPAA2_DQ_STAT_VOLATILE      0x02
     58/* volatile dequeue command is expired */
     59#define DPAA2_DQ_STAT_EXPIRED       0x01
     60
     61#define DQ_FQID_MASK		0x00FFFFFF
     62#define DQ_FRAME_COUNT_MASK	0x00FFFFFF
     63
     64/**
     65 * dpaa2_dq_flags() - Get the stat field of dequeue response
     66 * @dq: the dequeue result.
     67 */
     68static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
     69{
     70	return dq->dq.stat;
     71}
     72
     73/**
     74 * dpaa2_dq_is_pull() - Check whether the dq response is from a pull
     75 *                      command.
     76 * @dq: the dequeue result
     77 *
     78 * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
     79 */
     80static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
     81{
     82	return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
     83}
     84
     85/**
     86 * dpaa2_dq_is_pull_complete() - Check whether the pull command is completed.
     87 * @dq: the dequeue result
     88 *
     89 * Return boolean.
     90 */
     91static inline bool dpaa2_dq_is_pull_complete(const struct dpaa2_dq *dq)
     92{
     93	return !!(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_EXPIRED);
     94}
     95
     96/**
     97 * dpaa2_dq_seqnum() - Get the seqnum field in dequeue response
     98 * @dq: the dequeue result
     99 *
    100 * seqnum is valid only if VALIDFRAME flag is TRUE
    101 *
    102 * Return seqnum.
    103 */
    104static inline u16 dpaa2_dq_seqnum(const struct dpaa2_dq *dq)
    105{
    106	return le16_to_cpu(dq->dq.seqnum);
    107}
    108
    109/**
    110 * dpaa2_dq_odpid() - Get the odpid field in dequeue response
    111 * @dq: the dequeue result
    112 *
    113 * odpid is valid only if ODPVALID flag is TRUE.
    114 *
    115 * Return odpid.
    116 */
    117static inline u16 dpaa2_dq_odpid(const struct dpaa2_dq *dq)
    118{
    119	return le16_to_cpu(dq->dq.oprid);
    120}
    121
    122/**
    123 * dpaa2_dq_fqid() - Get the fqid in dequeue response
    124 * @dq: the dequeue result
    125 *
    126 * Return fqid.
    127 */
    128static inline u32 dpaa2_dq_fqid(const struct dpaa2_dq *dq)
    129{
    130	return le32_to_cpu(dq->dq.fqid) & DQ_FQID_MASK;
    131}
    132
    133/**
    134 * dpaa2_dq_byte_count() - Get the byte count in dequeue response
    135 * @dq: the dequeue result
    136 *
    137 * Return the byte count remaining in the FQ.
    138 */
    139static inline u32 dpaa2_dq_byte_count(const struct dpaa2_dq *dq)
    140{
    141	return le32_to_cpu(dq->dq.fq_byte_cnt);
    142}
    143
    144/**
    145 * dpaa2_dq_frame_count() - Get the frame count in dequeue response
    146 * @dq: the dequeue result
    147 *
    148 * Return the frame count remaining in the FQ.
    149 */
    150static inline u32 dpaa2_dq_frame_count(const struct dpaa2_dq *dq)
    151{
    152	return le32_to_cpu(dq->dq.fq_frm_cnt) & DQ_FRAME_COUNT_MASK;
    153}
    154
    155/**
    156 * dpaa2_dq_fd_ctx() - Get the frame queue context in dequeue response
    157 * @dq: the dequeue result
    158 *
    159 * Return the frame queue context.
    160 */
    161static inline u64 dpaa2_dq_fqd_ctx(const struct dpaa2_dq *dq)
    162{
    163	return le64_to_cpu(dq->dq.fqd_ctx);
    164}
    165
    166/**
    167 * dpaa2_dq_fd() - Get the frame descriptor in dequeue response
    168 * @dq: the dequeue result
    169 *
    170 * Return the frame descriptor.
    171 */
    172static inline const struct dpaa2_fd *dpaa2_dq_fd(const struct dpaa2_dq *dq)
    173{
    174	return (const struct dpaa2_fd *)&dq->dq.fd[0];
    175}
    176
    177#define DPAA2_CSCN_SIZE		sizeof(struct dpaa2_dq)
    178#define DPAA2_CSCN_ALIGN	16
    179#define DPAA2_CSCN_STATE_CG	BIT(0)
    180
    181/**
    182 * dpaa2_cscn_state_congested() - Check congestion state
    183 * @cscn: congestion SCN (delivered to WQ or memory)
    184 *
    185i * Return true is congested.
    186 */
    187static inline bool dpaa2_cscn_state_congested(struct dpaa2_dq *cscn)
    188{
    189	return !!(cscn->scn.state & DPAA2_CSCN_STATE_CG);
    190}
    191
    192#endif /* __FSL_DPAA2_GLOBAL_H */