18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_S390_PCI_CLP_H
38c2ecf20Sopenharmony_ci#define _ASM_S390_PCI_CLP_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/clp.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci * Call Logical Processor - Command Codes
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci#define CLP_SLPC		0x0001
118c2ecf20Sopenharmony_ci#define CLP_LIST_PCI		0x0002
128c2ecf20Sopenharmony_ci#define CLP_QUERY_PCI_FN	0x0003
138c2ecf20Sopenharmony_ci#define CLP_QUERY_PCI_FNGRP	0x0004
148c2ecf20Sopenharmony_ci#define CLP_SET_PCI_FN		0x0005
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* PCI function handle list entry */
178c2ecf20Sopenharmony_cistruct clp_fh_list_entry {
188c2ecf20Sopenharmony_ci	u16 device_id;
198c2ecf20Sopenharmony_ci	u16 vendor_id;
208c2ecf20Sopenharmony_ci	u32 config_state :  1;
218c2ecf20Sopenharmony_ci	u32		 : 31;
228c2ecf20Sopenharmony_ci	u32 fid;		/* PCI function id */
238c2ecf20Sopenharmony_ci	u32 fh;			/* PCI function handle */
248c2ecf20Sopenharmony_ci} __packed;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_FH	0x0101	/* Invalid PCI fn handle */
278c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_FHOP	0x0102	/* Fn handle not valid for op */
288c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_DMAAS	0x0103	/* Invalid DMA addr space */
298c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_RES	0x0104	/* Insufficient resources */
308c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_ALRDY	0x0105	/* Fn already in requested state */
318c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_ERR	0x0106	/* Fn in permanent error state */
328c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_RECPND	0x0107	/* Error recovery pending */
338c2ecf20Sopenharmony_ci#define CLP_RC_SETPCIFN_BUSY	0x0108	/* Fn busy */
348c2ecf20Sopenharmony_ci#define CLP_RC_LISTPCI_BADRT	0x010a	/* Resume token not recognized */
358c2ecf20Sopenharmony_ci#define CLP_RC_QUERYPCIFG_PFGID	0x010b	/* Unrecognized PFGID */
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/* request or response block header length */
388c2ecf20Sopenharmony_ci#define LIST_PCI_HDR_LEN	32
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* Number of function handles fitting in response block */
418c2ecf20Sopenharmony_ci#define CLP_FH_LIST_NR_ENTRIES				\
428c2ecf20Sopenharmony_ci	((CLP_BLK_SIZE - 2 * LIST_PCI_HDR_LEN)		\
438c2ecf20Sopenharmony_ci		/ sizeof(struct clp_fh_list_entry))
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define CLP_SET_ENABLE_PCI_FN	0	/* Yes, 0 enables it */
468c2ecf20Sopenharmony_ci#define CLP_SET_DISABLE_PCI_FN	1	/* Yes, 1 disables it */
478c2ecf20Sopenharmony_ci#define CLP_SET_ENABLE_MIO	2
488c2ecf20Sopenharmony_ci#define CLP_SET_DISABLE_MIO	3
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define CLP_UTIL_STR_LEN	64
518c2ecf20Sopenharmony_ci#define CLP_PFIP_NR_SEGMENTS	4
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciextern bool zpci_unique_uid;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct clp_rsp_slpc_pci {
568c2ecf20Sopenharmony_ci	struct clp_rsp_hdr hdr;
578c2ecf20Sopenharmony_ci	u32 reserved2[4];
588c2ecf20Sopenharmony_ci	u32 lpif[8];
598c2ecf20Sopenharmony_ci	u32 reserved3[4];
608c2ecf20Sopenharmony_ci	u32 vwb		:  1;
618c2ecf20Sopenharmony_ci	u32		:  1;
628c2ecf20Sopenharmony_ci	u32 mio_wb	:  6;
638c2ecf20Sopenharmony_ci	u32		: 24;
648c2ecf20Sopenharmony_ci	u32 reserved5[3];
658c2ecf20Sopenharmony_ci	u32 lpic[8];
668c2ecf20Sopenharmony_ci} __packed;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* List PCI functions request */
698c2ecf20Sopenharmony_cistruct clp_req_list_pci {
708c2ecf20Sopenharmony_ci	struct clp_req_hdr hdr;
718c2ecf20Sopenharmony_ci	u64 resume_token;
728c2ecf20Sopenharmony_ci	u64 reserved2;
738c2ecf20Sopenharmony_ci} __packed;
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* List PCI functions response */
768c2ecf20Sopenharmony_cistruct clp_rsp_list_pci {
778c2ecf20Sopenharmony_ci	struct clp_rsp_hdr hdr;
788c2ecf20Sopenharmony_ci	u64 resume_token;
798c2ecf20Sopenharmony_ci	u32 reserved2;
808c2ecf20Sopenharmony_ci	u16 max_fn;
818c2ecf20Sopenharmony_ci	u8			: 7;
828c2ecf20Sopenharmony_ci	u8 uid_checking		: 1;
838c2ecf20Sopenharmony_ci	u8 entry_size;
848c2ecf20Sopenharmony_ci	struct clp_fh_list_entry fh_list[CLP_FH_LIST_NR_ENTRIES];
858c2ecf20Sopenharmony_ci} __packed;
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistruct mio_info {
888c2ecf20Sopenharmony_ci	u32 valid : 6;
898c2ecf20Sopenharmony_ci	u32 : 26;
908c2ecf20Sopenharmony_ci	u32 : 32;
918c2ecf20Sopenharmony_ci	struct {
928c2ecf20Sopenharmony_ci		u64 wb;
938c2ecf20Sopenharmony_ci		u64 wt;
948c2ecf20Sopenharmony_ci	} addr[PCI_STD_NUM_BARS];
958c2ecf20Sopenharmony_ci	u32 reserved[6];
968c2ecf20Sopenharmony_ci} __packed;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/* Query PCI function request */
998c2ecf20Sopenharmony_cistruct clp_req_query_pci {
1008c2ecf20Sopenharmony_ci	struct clp_req_hdr hdr;
1018c2ecf20Sopenharmony_ci	u32 fh;				/* function handle */
1028c2ecf20Sopenharmony_ci	u32 reserved2;
1038c2ecf20Sopenharmony_ci	u64 reserved3;
1048c2ecf20Sopenharmony_ci} __packed;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* Query PCI function response */
1078c2ecf20Sopenharmony_cistruct clp_rsp_query_pci {
1088c2ecf20Sopenharmony_ci	struct clp_rsp_hdr hdr;
1098c2ecf20Sopenharmony_ci	u16 vfn;			/* virtual fn number */
1108c2ecf20Sopenharmony_ci	u16			:  3;
1118c2ecf20Sopenharmony_ci	u16 rid_avail		:  1;
1128c2ecf20Sopenharmony_ci	u16 is_physfn		:  1;
1138c2ecf20Sopenharmony_ci	u16 reserved1		:  1;
1148c2ecf20Sopenharmony_ci	u16 mio_addr_avail	:  1;
1158c2ecf20Sopenharmony_ci	u16 util_str_avail	:  1;	/* utility string available? */
1168c2ecf20Sopenharmony_ci	u16 pfgid		:  8;	/* pci function group id */
1178c2ecf20Sopenharmony_ci	u32 fid;			/* pci function id */
1188c2ecf20Sopenharmony_ci	u8 bar_size[PCI_STD_NUM_BARS];
1198c2ecf20Sopenharmony_ci	u16 pchid;
1208c2ecf20Sopenharmony_ci	__le32 bar[PCI_STD_NUM_BARS];
1218c2ecf20Sopenharmony_ci	u8 pfip[CLP_PFIP_NR_SEGMENTS];	/* pci function internal path */
1228c2ecf20Sopenharmony_ci	u16			: 12;
1238c2ecf20Sopenharmony_ci	u16 port		:  4;
1248c2ecf20Sopenharmony_ci	u8 fmb_len;
1258c2ecf20Sopenharmony_ci	u8 pft;				/* pci function type */
1268c2ecf20Sopenharmony_ci	u64 sdma;			/* start dma as */
1278c2ecf20Sopenharmony_ci	u64 edma;			/* end dma as */
1288c2ecf20Sopenharmony_ci#define ZPCI_RID_MASK_DEVFN 0x00ff
1298c2ecf20Sopenharmony_ci	u16 rid;			/* BUS/DEVFN PCI address */
1308c2ecf20Sopenharmony_ci	u16 reserved0;
1318c2ecf20Sopenharmony_ci	u32 reserved[10];
1328c2ecf20Sopenharmony_ci	u32 uid;			/* user defined id */
1338c2ecf20Sopenharmony_ci	u8 util_str[CLP_UTIL_STR_LEN];	/* utility string */
1348c2ecf20Sopenharmony_ci	u32 reserved2[16];
1358c2ecf20Sopenharmony_ci	struct mio_info mio;
1368c2ecf20Sopenharmony_ci} __packed;
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* Query PCI function group request */
1398c2ecf20Sopenharmony_cistruct clp_req_query_pci_grp {
1408c2ecf20Sopenharmony_ci	struct clp_req_hdr hdr;
1418c2ecf20Sopenharmony_ci	u32 reserved2		: 24;
1428c2ecf20Sopenharmony_ci	u32 pfgid		:  8;	/* function group id */
1438c2ecf20Sopenharmony_ci	u32 reserved3;
1448c2ecf20Sopenharmony_ci	u64 reserved4;
1458c2ecf20Sopenharmony_ci} __packed;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/* Query PCI function group response */
1488c2ecf20Sopenharmony_cistruct clp_rsp_query_pci_grp {
1498c2ecf20Sopenharmony_ci	struct clp_rsp_hdr hdr;
1508c2ecf20Sopenharmony_ci	u16			:  4;
1518c2ecf20Sopenharmony_ci	u16 noi			: 12;	/* number of interrupts */
1528c2ecf20Sopenharmony_ci	u8 version;
1538c2ecf20Sopenharmony_ci	u8			:  6;
1548c2ecf20Sopenharmony_ci	u8 frame		:  1;
1558c2ecf20Sopenharmony_ci	u8 refresh		:  1;	/* TLB refresh mode */
1568c2ecf20Sopenharmony_ci	u16 reserved2;
1578c2ecf20Sopenharmony_ci	u16 mui;
1588c2ecf20Sopenharmony_ci	u16			: 16;
1598c2ecf20Sopenharmony_ci	u16 maxfaal;
1608c2ecf20Sopenharmony_ci	u16			:  4;
1618c2ecf20Sopenharmony_ci	u16 dnoi		: 12;
1628c2ecf20Sopenharmony_ci	u16 maxcpu;
1638c2ecf20Sopenharmony_ci	u64 dasm;			/* dma address space mask */
1648c2ecf20Sopenharmony_ci	u64 msia;			/* MSI address */
1658c2ecf20Sopenharmony_ci	u64 reserved4;
1668c2ecf20Sopenharmony_ci	u64 reserved5;
1678c2ecf20Sopenharmony_ci} __packed;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* Set PCI function request */
1708c2ecf20Sopenharmony_cistruct clp_req_set_pci {
1718c2ecf20Sopenharmony_ci	struct clp_req_hdr hdr;
1728c2ecf20Sopenharmony_ci	u32 fh;				/* function handle */
1738c2ecf20Sopenharmony_ci	u16 reserved2;
1748c2ecf20Sopenharmony_ci	u8 oc;				/* operation controls */
1758c2ecf20Sopenharmony_ci	u8 ndas;			/* number of dma spaces */
1768c2ecf20Sopenharmony_ci	u64 reserved3;
1778c2ecf20Sopenharmony_ci} __packed;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* Set PCI function response */
1808c2ecf20Sopenharmony_cistruct clp_rsp_set_pci {
1818c2ecf20Sopenharmony_ci	struct clp_rsp_hdr hdr;
1828c2ecf20Sopenharmony_ci	u32 fh;				/* function handle */
1838c2ecf20Sopenharmony_ci	u32 reserved1;
1848c2ecf20Sopenharmony_ci	u64 reserved2;
1858c2ecf20Sopenharmony_ci	struct mio_info mio;
1868c2ecf20Sopenharmony_ci} __packed;
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* Combined request/response block structures used by clp insn */
1898c2ecf20Sopenharmony_cistruct clp_req_rsp_slpc_pci {
1908c2ecf20Sopenharmony_ci	struct clp_req_slpc request;
1918c2ecf20Sopenharmony_ci	struct clp_rsp_slpc_pci response;
1928c2ecf20Sopenharmony_ci} __packed;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistruct clp_req_rsp_list_pci {
1958c2ecf20Sopenharmony_ci	struct clp_req_list_pci request;
1968c2ecf20Sopenharmony_ci	struct clp_rsp_list_pci response;
1978c2ecf20Sopenharmony_ci} __packed;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistruct clp_req_rsp_set_pci {
2008c2ecf20Sopenharmony_ci	struct clp_req_set_pci request;
2018c2ecf20Sopenharmony_ci	struct clp_rsp_set_pci response;
2028c2ecf20Sopenharmony_ci} __packed;
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistruct clp_req_rsp_query_pci {
2058c2ecf20Sopenharmony_ci	struct clp_req_query_pci request;
2068c2ecf20Sopenharmony_ci	struct clp_rsp_query_pci response;
2078c2ecf20Sopenharmony_ci} __packed;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct clp_req_rsp_query_pci_grp {
2108c2ecf20Sopenharmony_ci	struct clp_req_query_pci_grp request;
2118c2ecf20Sopenharmony_ci	struct clp_rsp_query_pci_grp response;
2128c2ecf20Sopenharmony_ci} __packed;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#endif
215