18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * Copyright 2016-2018 HabanaLabs, Ltd.
48c2ecf20Sopenharmony_ci * All Rights Reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef QMAN_IF_H
98c2ecf20Sopenharmony_ci#define QMAN_IF_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/types.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * PRIMARY QUEUE
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct hl_bd {
188c2ecf20Sopenharmony_ci	__le64	ptr;
198c2ecf20Sopenharmony_ci	__le32	len;
208c2ecf20Sopenharmony_ci	__le32	ctl;
218c2ecf20Sopenharmony_ci};
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define HL_BD_SIZE			sizeof(struct hl_bd)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * S/W CTL FIELDS.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * BD_CTL_REPEAT_VALID tells the CP whether the repeat field in the BD CTL is
298c2ecf20Sopenharmony_ci * valid. 1 means the repeat field is valid, 0 means not-valid,
308c2ecf20Sopenharmony_ci * i.e. repeat == 1
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci#define BD_CTL_REPEAT_VALID_SHIFT	24
338c2ecf20Sopenharmony_ci#define BD_CTL_REPEAT_VALID_MASK	0x01000000
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define BD_CTL_SHADOW_INDEX_SHIFT	0
368c2ecf20Sopenharmony_ci#define BD_CTL_SHADOW_INDEX_MASK	0x00000FFF
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/*
398c2ecf20Sopenharmony_ci * H/W CTL FIELDS
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define BD_CTL_COMP_OFFSET_SHIFT	16
438c2ecf20Sopenharmony_ci#define BD_CTL_COMP_OFFSET_MASK		0x0FFF0000
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define BD_CTL_COMP_DATA_SHIFT		0
468c2ecf20Sopenharmony_ci#define BD_CTL_COMP_DATA_MASK		0x0000FFFF
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*
498c2ecf20Sopenharmony_ci * COMPLETION QUEUE
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct hl_cq_entry {
538c2ecf20Sopenharmony_ci	__le32	data;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define HL_CQ_ENTRY_SIZE		sizeof(struct hl_cq_entry)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#define CQ_ENTRY_READY_SHIFT			31
598c2ecf20Sopenharmony_ci#define CQ_ENTRY_READY_MASK			0x80000000
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define CQ_ENTRY_SHADOW_INDEX_VALID_SHIFT	30
628c2ecf20Sopenharmony_ci#define CQ_ENTRY_SHADOW_INDEX_VALID_MASK	0x40000000
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define CQ_ENTRY_SHADOW_INDEX_SHIFT		BD_CTL_SHADOW_INDEX_SHIFT
658c2ecf20Sopenharmony_ci#define CQ_ENTRY_SHADOW_INDEX_MASK		BD_CTL_SHADOW_INDEX_MASK
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#endif /* QMAN_IF_H */
69