0001
0002
0003
0004
0005
0006
0007 #ifndef __FSL_DPAA2_GLOBAL_H
0008 #define __FSL_DPAA2_GLOBAL_H
0009
0010 #include <linux/types.h>
0011 #include <linux/cpumask.h>
0012 #include "dpaa2-fd.h"
0013
0014 struct dpaa2_dq {
0015 union {
0016 struct common {
0017 u8 verb;
0018 u8 reserved[63];
0019 } common;
0020 struct dq {
0021 u8 verb;
0022 u8 stat;
0023 __le16 seqnum;
0024 __le16 oprid;
0025 u8 reserved;
0026 u8 tok;
0027 __le32 fqid;
0028 u32 reserved2;
0029 __le32 fq_byte_cnt;
0030 __le32 fq_frm_cnt;
0031 __le64 fqd_ctx;
0032 u8 fd[32];
0033 } dq;
0034 struct scn {
0035 u8 verb;
0036 u8 stat;
0037 u8 state;
0038 u8 reserved;
0039 __le32 rid_tok;
0040 __le64 ctx;
0041 } scn;
0042 };
0043 };
0044
0045
0046
0047 #define DPAA2_DQ_STAT_FQEMPTY 0x80
0048
0049 #define DPAA2_DQ_STAT_HELDACTIVE 0x40
0050
0051 #define DPAA2_DQ_STAT_FORCEELIGIBLE 0x20
0052
0053 #define DPAA2_DQ_STAT_VALIDFRAME 0x10
0054
0055 #define DPAA2_DQ_STAT_ODPVALID 0x04
0056
0057 #define DPAA2_DQ_STAT_VOLATILE 0x02
0058
0059 #define DPAA2_DQ_STAT_EXPIRED 0x01
0060
0061 #define DQ_FQID_MASK 0x00FFFFFF
0062 #define DQ_FRAME_COUNT_MASK 0x00FFFFFF
0063
0064
0065
0066
0067
0068 static inline u32 dpaa2_dq_flags(const struct dpaa2_dq *dq)
0069 {
0070 return dq->dq.stat;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080 static inline int dpaa2_dq_is_pull(const struct dpaa2_dq *dq)
0081 {
0082 return (int)(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_VOLATILE);
0083 }
0084
0085
0086
0087
0088
0089
0090
0091 static inline bool dpaa2_dq_is_pull_complete(const struct dpaa2_dq *dq)
0092 {
0093 return !!(dpaa2_dq_flags(dq) & DPAA2_DQ_STAT_EXPIRED);
0094 }
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 static inline u16 dpaa2_dq_seqnum(const struct dpaa2_dq *dq)
0105 {
0106 return le16_to_cpu(dq->dq.seqnum);
0107 }
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 static inline u16 dpaa2_dq_odpid(const struct dpaa2_dq *dq)
0118 {
0119 return le16_to_cpu(dq->dq.oprid);
0120 }
0121
0122
0123
0124
0125
0126
0127
0128 static inline u32 dpaa2_dq_fqid(const struct dpaa2_dq *dq)
0129 {
0130 return le32_to_cpu(dq->dq.fqid) & DQ_FQID_MASK;
0131 }
0132
0133
0134
0135
0136
0137
0138
0139 static inline u32 dpaa2_dq_byte_count(const struct dpaa2_dq *dq)
0140 {
0141 return le32_to_cpu(dq->dq.fq_byte_cnt);
0142 }
0143
0144
0145
0146
0147
0148
0149
0150 static inline u32 dpaa2_dq_frame_count(const struct dpaa2_dq *dq)
0151 {
0152 return le32_to_cpu(dq->dq.fq_frm_cnt) & DQ_FRAME_COUNT_MASK;
0153 }
0154
0155
0156
0157
0158
0159
0160
0161 static inline u64 dpaa2_dq_fqd_ctx(const struct dpaa2_dq *dq)
0162 {
0163 return le64_to_cpu(dq->dq.fqd_ctx);
0164 }
0165
0166
0167
0168
0169
0170
0171
0172 static inline const struct dpaa2_fd *dpaa2_dq_fd(const struct dpaa2_dq *dq)
0173 {
0174 return (const struct dpaa2_fd *)&dq->dq.fd[0];
0175 }
0176
0177 #define DPAA2_CSCN_SIZE sizeof(struct dpaa2_dq)
0178 #define DPAA2_CSCN_ALIGN 16
0179 #define DPAA2_CSCN_STATE_CG BIT(0)
0180
0181
0182
0183
0184
0185
0186
0187 static inline bool dpaa2_cscn_state_congested(struct dpaa2_dq *cscn)
0188 {
0189 return !!(cscn->scn.state & DPAA2_CSCN_STATE_CG);
0190 }
0191
0192 #endif