1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. 4 */ 5 #ifndef __NVIF_CHAN_H__ 6 #define __NVIF_CHAN_H__ 7 #include "push.h" 8 9 struct nvif_chan { 10 const struct nvif_chan_func { 11 struct { 12 u32 (*read_get)(struct nvif_chan *); 13 } push; 14 15 struct { 16 u32 (*read_get)(struct nvif_chan *); 17 void (*push)(struct nvif_chan *, bool main, u64 addr, u32 size, 18 bool no_prefetch); 19 void (*kick)(struct nvif_chan *); 20 int (*post)(struct nvif_chan *, u32 gpptr, u32 pbptr); 21 u32 post_size; 22 } gpfifo; 23 24 struct { 25 int (*release)(struct nvif_chan *, u64 addr, u32 data); 26 } sem; 27 } *func; 28 29 struct { 30 struct nvif_map map; 31 } userd; 32 33 struct { 34 struct nvif_map map; 35 u32 cur; 36 u32 max; 37 int free; 38 } gpfifo; 39 40 struct { 41 struct nvif_map map; 42 u64 addr; 43 } sema; 44 45 struct nvif_push push; 46 47 struct nvif_user *usermode; 48 u32 doorbell_token; 49 }; 50 51 int nvif_chan_dma_wait(struct nvif_chan *, u32 push_nr); 52 53 void nvif_chan_gpfifo_ctor(const struct nvif_chan_func *, void *userd, void *gpfifo, u32 gpfifo_size, 54 void *push, u64 push_addr, u32 push_size, struct nvif_chan *); 55 int nvif_chan_gpfifo_wait(struct nvif_chan *, u32 gpfifo_nr, u32 push_nr); 56 void nvif_chan_gpfifo_push(struct nvif_chan *, u64 addr, u32 size, bool no_prefetch); 57 int nvif_chan_gpfifo_post(struct nvif_chan *); 58 59 void nvif_chan506f_gpfifo_push(struct nvif_chan *, bool main, u64 addr, u32 size, bool no_prefetch); 60 void nvif_chan506f_gpfifo_kick(struct nvif_chan *); 61 62 int nvif_chan906f_ctor_(const struct nvif_chan_func *, void *userd, void *gpfifo, u32 gpfifo_size, 63 void *push, u64 push_addr, u32 push_size, void *sema, u64 sema_addr, 64 struct nvif_chan *); 65 u32 nvif_chan906f_read_get(struct nvif_chan *); 66 u32 nvif_chan906f_gpfifo_read_get(struct nvif_chan *); 67 int nvif_chan906f_gpfifo_post(struct nvif_chan *, u32 gpptr, u32 pbptr); 68 69 int nvif_chan506f_ctor(struct nvif_chan *, void *userd, void *gpfifo, u32 gpfifo_size, 70 void *push, u64 push_addr, u32 push_size); 71 int nvif_chan906f_ctor(struct nvif_chan *, void *userd, void *gpfifo, u32 gpfifo_size, 72 void *push, u64 push_addr, u32 push_size, void *sema, u64 sema_addr); 73 int nvif_chanc36f_ctor(struct nvif_chan *, void *userd, void *gpfifo, u32 gpfifo_size, 74 void *push, u64 push_addr, u32 push_size, void *sema, u64 sema_addr, 75 struct nvif_user *usermode, u32 doorbell_token); 76 #endif 77