brintos

brintos / linux-shallow public Read only

0
0
Text · 1.8 KiB · 0eb4ba2 Raw
67 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright 2008 Cisco Systems, Inc.  All rights reserved.4 * Copyright 2007 Nuova Systems, Inc.  All rights reserved.5 */6#ifndef _CQ_DESC_H_7#define _CQ_DESC_H_8 9/*10 * Completion queue descriptor types11 */12enum cq_desc_types {13	CQ_DESC_TYPE_WQ_ENET = 0,14	CQ_DESC_TYPE_DESC_COPY = 1,15	CQ_DESC_TYPE_WQ_EXCH = 2,16	CQ_DESC_TYPE_RQ_ENET = 3,17	CQ_DESC_TYPE_RQ_FCP = 4,18};19 20/* Completion queue descriptor: 16B21 *22 * All completion queues have this basic layout.  The23 * type_specfic area is unique for each completion24 * queue type.25 */26struct cq_desc {27	__le16 completed_index;28	__le16 q_number;29	u8 type_specfic[11];30	u8 type_color;31};32 33#define CQ_DESC_TYPE_BITS        434#define CQ_DESC_TYPE_MASK        ((1 << CQ_DESC_TYPE_BITS) - 1)35#define CQ_DESC_COLOR_MASK       136#define CQ_DESC_COLOR_SHIFT      737#define CQ_DESC_Q_NUM_BITS       1038#define CQ_DESC_Q_NUM_MASK       ((1 << CQ_DESC_Q_NUM_BITS) - 1)39#define CQ_DESC_COMP_NDX_BITS    1240#define CQ_DESC_COMP_NDX_MASK    ((1 << CQ_DESC_COMP_NDX_BITS) - 1)41 42static inline void cq_desc_dec(const struct cq_desc *desc_arg,43	u8 *type, u8 *color, u16 *q_number, u16 *completed_index)44{45	const struct cq_desc *desc = desc_arg;46	const u8 type_color = desc->type_color;47 48	*color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;49 50	/*51	 * Make sure color bit is read from desc *before* other fields52	 * are read from desc.  Hardware guarantees color bit is last53	 * bit (byte) written.  Adding the rmb() prevents the compiler54	 * and/or CPU from reordering the reads which would potentially55	 * result in reading stale values.56	 */57 58	rmb();59 60	*type = type_color & CQ_DESC_TYPE_MASK;61	*q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK;62	*completed_index = le16_to_cpu(desc->completed_index) &63		CQ_DESC_COMP_NDX_MASK;64}65 66#endif /* _CQ_DESC_H_ */67