xref: /linux/drivers/iommu/generic_pt/fmt/iommu_template.h (revision ce5cfb0fa20dc6454da039612e34325b7b4a8243)
1cdb39d91SJason Gunthorpe /* SPDX-License-Identifier: GPL-2.0-only */
2cdb39d91SJason Gunthorpe /*
3cdb39d91SJason Gunthorpe  * Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES
4cdb39d91SJason Gunthorpe  *
5cdb39d91SJason Gunthorpe  * Template to build the iommu module and kunit from the format and
6cdb39d91SJason Gunthorpe  * implementation headers.
7cdb39d91SJason Gunthorpe  *
8cdb39d91SJason Gunthorpe  * The format should have:
9cdb39d91SJason Gunthorpe  *  #define PT_FMT <name>
10cdb39d91SJason Gunthorpe  *  #define PT_SUPPORTED_FEATURES (BIT(PT_FEAT_xx) | BIT(PT_FEAT_yy))
11cdb39d91SJason Gunthorpe  * And optionally:
12cdb39d91SJason Gunthorpe  *  #define PT_FORCE_ENABLED_FEATURES ..
13cdb39d91SJason Gunthorpe  *  #define PT_FMT_VARIANT <suffix>
14cdb39d91SJason Gunthorpe  */
15cdb39d91SJason Gunthorpe #include <linux/args.h>
16cdb39d91SJason Gunthorpe #include <linux/stringify.h>
17cdb39d91SJason Gunthorpe 
18cdb39d91SJason Gunthorpe #ifdef PT_FMT_VARIANT
19cdb39d91SJason Gunthorpe #define PTPFX_RAW \
20cdb39d91SJason Gunthorpe 	CONCATENATE(CONCATENATE(PT_FMT, _), PT_FMT_VARIANT)
21cdb39d91SJason Gunthorpe #else
22cdb39d91SJason Gunthorpe #define PTPFX_RAW PT_FMT
23cdb39d91SJason Gunthorpe #endif
24cdb39d91SJason Gunthorpe 
25cdb39d91SJason Gunthorpe #define PTPFX CONCATENATE(PTPFX_RAW, _)
26cdb39d91SJason Gunthorpe 
27cdb39d91SJason Gunthorpe #define _PT_FMT_H PT_FMT.h
28cdb39d91SJason Gunthorpe #define PT_FMT_H __stringify(_PT_FMT_H)
29cdb39d91SJason Gunthorpe 
30cdb39d91SJason Gunthorpe #define _PT_DEFS_H CONCATENATE(defs_, _PT_FMT_H)
31cdb39d91SJason Gunthorpe #define PT_DEFS_H __stringify(_PT_DEFS_H)
32cdb39d91SJason Gunthorpe 
33cdb39d91SJason Gunthorpe #include <linux/generic_pt/common.h>
34cdb39d91SJason Gunthorpe #include PT_DEFS_H
35cdb39d91SJason Gunthorpe #include "../pt_defs.h"
36cdb39d91SJason Gunthorpe #include PT_FMT_H
37cdb39d91SJason Gunthorpe #include "../pt_common.h"
38cdb39d91SJason Gunthorpe 
391dd4187fSJason Gunthorpe #ifndef GENERIC_PT_KUNIT
40cdb39d91SJason Gunthorpe #include "../iommu_pt.h"
411dd4187fSJason Gunthorpe #else
421dd4187fSJason Gunthorpe /*
431dd4187fSJason Gunthorpe  * The makefile will compile the .c file twice, once with GENERIC_PT_KUNIT set
441dd4187fSJason Gunthorpe  * which means we are building the kunit modle.
451dd4187fSJason Gunthorpe  */
461dd4187fSJason Gunthorpe #include "../kunit_generic_pt.h"
47*bc5233c0SJason Gunthorpe #include "../kunit_iommu_pt.h"
481dd4187fSJason Gunthorpe #endif
49