History

switchtec: Add IOCTLs to the Switchtec driver

Add a couple of special IOCTLs to: * Inform userspace of firmware partition locations * Pass event counts and allow userspace to wait on events * Translate PFF numbers used by the switch to port numbers [Dan Carpenter <dan.carpenter@oracle.com>: fix off-by-one in ioctl_event_ctl()] Tested-by: Krishna Dhulipala <krishnad@fb.com> Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Stephen Bates <stephen.bates@microsemi.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Wei Zhang <wzhang@fb.com> Reviewed-by: Jens Axboe <axboe@fb.com>

Logan Gunthorpe committed 9 years ago

Commit 52eabba1 parent 5d8e1885 files · +642 −0Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/switchtec_ioctl.h+132−0
@@ -0,0 +1,132 @@
1+/*
2+ * Microsemi Switchtec PCIe Driver
3+ * Copyright (c) 2017, Microsemi Corporation
4+ *
5+ * This program is free software; you can redistribute it and/or modify it
6+ * under the terms and conditions of the GNU General Public License,
7+ * version 2, as published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope it will be useful, but WITHOUT
10+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+ * more details.
13+ *
14+ */
15+
16+#ifndef _UAPI_LINUX_SWITCHTEC_IOCTL_H
17+#define _UAPI_LINUX_SWITCHTEC_IOCTL_H
18+
19+#include <linux/types.h>
20+
21+#define SWITCHTEC_IOCTL_PART_CFG0 0
22+#define SWITCHTEC_IOCTL_PART_CFG1 1
23+#define SWITCHTEC_IOCTL_PART_IMG0 2
24+#define SWITCHTEC_IOCTL_PART_IMG1 3
25+#define SWITCHTEC_IOCTL_PART_NVLOG 4
26+#define SWITCHTEC_IOCTL_PART_VENDOR0 5
27+#define SWITCHTEC_IOCTL_PART_VENDOR1 6
28+#define SWITCHTEC_IOCTL_PART_VENDOR2 7
29+#define SWITCHTEC_IOCTL_PART_VENDOR3 8
30+#define SWITCHTEC_IOCTL_PART_VENDOR4 9
31+#define SWITCHTEC_IOCTL_PART_VENDOR5 10
32+#define SWITCHTEC_IOCTL_PART_VENDOR6 11
33+#define SWITCHTEC_IOCTL_PART_VENDOR7 12
34+#define SWITCHTEC_IOCTL_NUM_PARTITIONS 13
35+
36+struct switchtec_ioctl_flash_info {
37+ __u64 flash_length;
38+ __u32 num_partitions;
39+ __u32 padding;
40+};
41+
42+struct switchtec_ioctl_flash_part_info {
43+ __u32 flash_partition;
44+ __u32 address;
45+ __u32 length;
46+ __u32 active;
47+};
48+
49+struct switchtec_ioctl_event_summary {
50+ __u64 global;
51+ __u64 part_bitmap;
52+ __u32 local_part;
53+ __u32 padding;
54+ __u32 part[48];
55+ __u32 pff[48];
56+};
57+
58+#define SWITCHTEC_IOCTL_EVENT_STACK_ERROR 0
59+#define SWITCHTEC_IOCTL_EVENT_PPU_ERROR 1
60+#define SWITCHTEC_IOCTL_EVENT_ISP_ERROR 2
61+#define SWITCHTEC_IOCTL_EVENT_SYS_RESET 3
62+#define SWITCHTEC_IOCTL_EVENT_FW_EXC 4
63+#define SWITCHTEC_IOCTL_EVENT_FW_NMI 5
64+#define SWITCHTEC_IOCTL_EVENT_FW_NON_FATAL 6
65+#define SWITCHTEC_IOCTL_EVENT_FW_FATAL 7
66+#define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP 8
67+#define SWITCHTEC_IOCTL_EVENT_TWI_MRPC_COMP_ASYNC 9
68+#define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP 10
69+#define SWITCHTEC_IOCTL_EVENT_CLI_MRPC_COMP_ASYNC 11
70+#define SWITCHTEC_IOCTL_EVENT_GPIO_INT 12
71+#define SWITCHTEC_IOCTL_EVENT_PART_RESET 13
72+#define SWITCHTEC_IOCTL_EVENT_MRPC_COMP 14
73+#define SWITCHTEC_IOCTL_EVENT_MRPC_COMP_ASYNC 15
74+#define SWITCHTEC_IOCTL_EVENT_DYN_PART_BIND_COMP 16
75+#define SWITCHTEC_IOCTL_EVENT_AER_IN_P2P 17
76+#define SWITCHTEC_IOCTL_EVENT_AER_IN_VEP 18
77+#define SWITCHTEC_IOCTL_EVENT_DPC 19
78+#define SWITCHTEC_IOCTL_EVENT_CTS 20
79+#define SWITCHTEC_IOCTL_EVENT_HOTPLUG 21
80+#define SWITCHTEC_IOCTL_EVENT_IER 22
81+#define SWITCHTEC_IOCTL_EVENT_THRESH 23
82+#define SWITCHTEC_IOCTL_EVENT_POWER_MGMT 24
83+#define SWITCHTEC_IOCTL_EVENT_TLP_THROTTLING 25
84+#define SWITCHTEC_IOCTL_EVENT_FORCE_SPEED 26
85+#define SWITCHTEC_IOCTL_EVENT_CREDIT_TIMEOUT 27
86+#define SWITCHTEC_IOCTL_EVENT_LINK_STATE 28
87+#define SWITCHTEC_IOCTL_MAX_EVENTS 29
88+
89+#define SWITCHTEC_IOCTL_EVENT_LOCAL_PART_IDX -1
90+#define SWITCHTEC_IOCTL_EVENT_IDX_ALL -2
91+
92+#define SWITCHTEC_IOCTL_EVENT_FLAG_CLEAR (1 << 0)
93+#define SWITCHTEC_IOCTL_EVENT_FLAG_EN_POLL (1 << 1)
94+#define SWITCHTEC_IOCTL_EVENT_FLAG_EN_LOG (1 << 2)
95+#define SWITCHTEC_IOCTL_EVENT_FLAG_EN_CLI (1 << 3)
96+#define SWITCHTEC_IOCTL_EVENT_FLAG_EN_FATAL (1 << 4)
97+#define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_POLL (1 << 5)
98+#define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_LOG (1 << 6)
99+#define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_CLI (1 << 7)
100+#define SWITCHTEC_IOCTL_EVENT_FLAG_DIS_FATAL (1 << 8)
101+#define SWITCHTEC_IOCTL_EVENT_FLAG_UNUSED (~0x1ff)
102+
103+struct switchtec_ioctl_event_ctl {
104+ __u32 event_id;
105+ __s32 index;
106+ __u32 flags;
107+ __u32 occurred;
108+ __u32 count;
109+ __u32 data[5];
110+};
111+
112+#define SWITCHTEC_IOCTL_PFF_VEP 100
113+struct switchtec_ioctl_pff_port {
114+ __u32 pff;
115+ __u32 partition;
116+ __u32 port;
117+};
118+
119+#define SWITCHTEC_IOCTL_FLASH_INFO \
120+ _IOR('W', 0x40, struct switchtec_ioctl_flash_info)
121+#define SWITCHTEC_IOCTL_FLASH_PART_INFO \
122+ _IOWR('W', 0x41, struct switchtec_ioctl_flash_part_info)
123+#define SWITCHTEC_IOCTL_EVENT_SUMMARY \
124+ _IOR('W', 0x42, struct switchtec_ioctl_event_summary)
125+#define SWITCHTEC_IOCTL_EVENT_CTL \
126+ _IOWR('W', 0x43, struct switchtec_ioctl_event_ctl)
127+#define SWITCHTEC_IOCTL_PFF_TO_PORT \
128+ _IOWR('W', 0x44, struct switchtec_ioctl_pff_port)
129+#define SWITCHTEC_IOCTL_PORT_TO_PFF \
130+ _IOWR('W', 0x45, struct switchtec_ioctl_pff_port)
131+
132+#endif