162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
462306a36Sopenharmony_ci * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef RXE_OPCODE_H
862306a36Sopenharmony_ci#define RXE_OPCODE_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/*
1162306a36Sopenharmony_ci * contains header bit mask definitions and header lengths
1262306a36Sopenharmony_ci * declaration of the rxe_opcode_info struct and
1362306a36Sopenharmony_ci * rxe_wr_opcode_info struct
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cienum rxe_wr_mask {
1762306a36Sopenharmony_ci	WR_INLINE_MASK			= BIT(0),
1862306a36Sopenharmony_ci	WR_ATOMIC_MASK			= BIT(1),
1962306a36Sopenharmony_ci	WR_SEND_MASK			= BIT(2),
2062306a36Sopenharmony_ci	WR_READ_MASK			= BIT(3),
2162306a36Sopenharmony_ci	WR_WRITE_MASK			= BIT(4),
2262306a36Sopenharmony_ci	WR_LOCAL_OP_MASK		= BIT(5),
2362306a36Sopenharmony_ci	WR_FLUSH_MASK			= BIT(6),
2462306a36Sopenharmony_ci	WR_ATOMIC_WRITE_MASK		= BIT(7),
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci	WR_READ_OR_WRITE_MASK		= WR_READ_MASK | WR_WRITE_MASK,
2762306a36Sopenharmony_ci	WR_WRITE_OR_SEND_MASK		= WR_WRITE_MASK | WR_SEND_MASK,
2862306a36Sopenharmony_ci	WR_ATOMIC_OR_READ_MASK		= WR_ATOMIC_MASK | WR_READ_MASK,
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define WR_MAX_QPT		(8)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cistruct rxe_wr_opcode_info {
3462306a36Sopenharmony_ci	char			*name;
3562306a36Sopenharmony_ci	enum rxe_wr_mask	mask[WR_MAX_QPT];
3662306a36Sopenharmony_ci};
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciextern struct rxe_wr_opcode_info rxe_wr_opcode_info[];
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cienum rxe_hdr_type {
4162306a36Sopenharmony_ci	RXE_LRH,
4262306a36Sopenharmony_ci	RXE_GRH,
4362306a36Sopenharmony_ci	RXE_BTH,
4462306a36Sopenharmony_ci	RXE_RETH,
4562306a36Sopenharmony_ci	RXE_AETH,
4662306a36Sopenharmony_ci	RXE_ATMETH,
4762306a36Sopenharmony_ci	RXE_ATMACK,
4862306a36Sopenharmony_ci	RXE_IETH,
4962306a36Sopenharmony_ci	RXE_RDETH,
5062306a36Sopenharmony_ci	RXE_DETH,
5162306a36Sopenharmony_ci	RXE_IMMDT,
5262306a36Sopenharmony_ci	RXE_FETH,
5362306a36Sopenharmony_ci	RXE_PAYLOAD,
5462306a36Sopenharmony_ci	NUM_HDR_TYPES
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cienum rxe_hdr_mask {
5862306a36Sopenharmony_ci	RXE_LRH_MASK		= BIT(RXE_LRH),
5962306a36Sopenharmony_ci	RXE_GRH_MASK		= BIT(RXE_GRH),
6062306a36Sopenharmony_ci	RXE_BTH_MASK		= BIT(RXE_BTH),
6162306a36Sopenharmony_ci	RXE_IMMDT_MASK		= BIT(RXE_IMMDT),
6262306a36Sopenharmony_ci	RXE_RETH_MASK		= BIT(RXE_RETH),
6362306a36Sopenharmony_ci	RXE_AETH_MASK		= BIT(RXE_AETH),
6462306a36Sopenharmony_ci	RXE_ATMETH_MASK		= BIT(RXE_ATMETH),
6562306a36Sopenharmony_ci	RXE_ATMACK_MASK		= BIT(RXE_ATMACK),
6662306a36Sopenharmony_ci	RXE_IETH_MASK		= BIT(RXE_IETH),
6762306a36Sopenharmony_ci	RXE_RDETH_MASK		= BIT(RXE_RDETH),
6862306a36Sopenharmony_ci	RXE_DETH_MASK		= BIT(RXE_DETH),
6962306a36Sopenharmony_ci	RXE_FETH_MASK		= BIT(RXE_FETH),
7062306a36Sopenharmony_ci	RXE_PAYLOAD_MASK	= BIT(RXE_PAYLOAD),
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci	RXE_REQ_MASK		= BIT(NUM_HDR_TYPES + 0),
7362306a36Sopenharmony_ci	RXE_ACK_MASK		= BIT(NUM_HDR_TYPES + 1),
7462306a36Sopenharmony_ci	RXE_SEND_MASK		= BIT(NUM_HDR_TYPES + 2),
7562306a36Sopenharmony_ci	RXE_WRITE_MASK		= BIT(NUM_HDR_TYPES + 3),
7662306a36Sopenharmony_ci	RXE_READ_MASK		= BIT(NUM_HDR_TYPES + 4),
7762306a36Sopenharmony_ci	RXE_ATOMIC_MASK		= BIT(NUM_HDR_TYPES + 5),
7862306a36Sopenharmony_ci	RXE_FLUSH_MASK		= BIT(NUM_HDR_TYPES + 6),
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci	RXE_RWR_MASK		= BIT(NUM_HDR_TYPES + 7),
8162306a36Sopenharmony_ci	RXE_COMP_MASK		= BIT(NUM_HDR_TYPES + 8),
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	RXE_START_MASK		= BIT(NUM_HDR_TYPES + 9),
8462306a36Sopenharmony_ci	RXE_MIDDLE_MASK		= BIT(NUM_HDR_TYPES + 10),
8562306a36Sopenharmony_ci	RXE_END_MASK		= BIT(NUM_HDR_TYPES + 11),
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	RXE_LOOPBACK_MASK	= BIT(NUM_HDR_TYPES + 12),
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci	RXE_ATOMIC_WRITE_MASK   = BIT(NUM_HDR_TYPES + 14),
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci	RXE_READ_OR_ATOMIC_MASK	= (RXE_READ_MASK | RXE_ATOMIC_MASK),
9262306a36Sopenharmony_ci	RXE_WRITE_OR_SEND_MASK	= (RXE_WRITE_MASK | RXE_SEND_MASK),
9362306a36Sopenharmony_ci	RXE_READ_OR_WRITE_MASK	= (RXE_READ_MASK | RXE_WRITE_MASK),
9462306a36Sopenharmony_ci	RXE_RDMA_OP_MASK	= (RXE_READ_MASK | RXE_WRITE_MASK |
9562306a36Sopenharmony_ci				   RXE_ATOMIC_WRITE_MASK | RXE_FLUSH_MASK |
9662306a36Sopenharmony_ci				   RXE_ATOMIC_MASK),
9762306a36Sopenharmony_ci};
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define OPCODE_NONE		(-1)
10062306a36Sopenharmony_ci#define RXE_NUM_OPCODE		256
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_cistruct rxe_opcode_info {
10362306a36Sopenharmony_ci	char			*name;
10462306a36Sopenharmony_ci	enum rxe_hdr_mask	mask;
10562306a36Sopenharmony_ci	int			length;
10662306a36Sopenharmony_ci	int			offset[NUM_HDR_TYPES];
10762306a36Sopenharmony_ci};
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciextern struct rxe_opcode_info rxe_opcode[RXE_NUM_OPCODE];
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#endif /* RXE_OPCODE_H */
112