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