0001
0002
0003
0004
0005
0006 #ifndef _CQ_DESC_H_
0007 #define _CQ_DESC_H_
0008
0009
0010
0011
0012 enum cq_desc_types {
0013 CQ_DESC_TYPE_WQ_ENET = 0,
0014 CQ_DESC_TYPE_DESC_COPY = 1,
0015 CQ_DESC_TYPE_WQ_EXCH = 2,
0016 CQ_DESC_TYPE_RQ_ENET = 3,
0017 CQ_DESC_TYPE_RQ_FCP = 4,
0018 };
0019
0020
0021
0022
0023
0024
0025
0026 struct cq_desc {
0027 __le16 completed_index;
0028 __le16 q_number;
0029 u8 type_specfic[11];
0030 u8 type_color;
0031 };
0032
0033 #define CQ_DESC_TYPE_BITS 4
0034 #define CQ_DESC_TYPE_MASK ((1 << CQ_DESC_TYPE_BITS) - 1)
0035 #define CQ_DESC_COLOR_MASK 1
0036 #define CQ_DESC_COLOR_SHIFT 7
0037 #define CQ_DESC_Q_NUM_BITS 10
0038 #define CQ_DESC_Q_NUM_MASK ((1 << CQ_DESC_Q_NUM_BITS) - 1)
0039 #define CQ_DESC_COMP_NDX_BITS 12
0040 #define CQ_DESC_COMP_NDX_MASK ((1 << CQ_DESC_COMP_NDX_BITS) - 1)
0041
0042 static inline void cq_desc_dec(const struct cq_desc *desc_arg,
0043 u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
0044 {
0045 const struct cq_desc *desc = desc_arg;
0046 const u8 type_color = desc->type_color;
0047
0048 *color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 rmb();
0059
0060 *type = type_color & CQ_DESC_TYPE_MASK;
0061 *q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK;
0062 *completed_index = le16_to_cpu(desc->completed_index) &
0063 CQ_DESC_COMP_NDX_MASK;
0064 }
0065
0066 #endif