xref: /freebsd/sys/dev/bxe/bxe_ioctl.h (revision 0d66206fff44f864ea8a4b220c3a53b4caa959a0)
1 /*
2  * Copyright (c) 2015-2016 Qlogic Corporation
3  * All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  *  2. Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef _BXE_IOCTL_H_
29 #define _BXE_IOCTL_H_
30 
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
33 
34 #include <sys/ioccom.h>
35 
36 
37 struct bxe_grcdump {
38     uint16_t pci_func;
39     uint32_t grcdump_size;
40     void *grcdump;
41     uint32_t grcdump_dwords;
42 };
43 typedef struct bxe_grcdump bxe_grcdump_t;
44 
45 #define BXE_DRV_NAME_LENGTH             32
46 #define BXE_DRV_VERSION_LENGTH          32
47 #define BXE_MFW_VERSION_LENGTH          32
48 #define BXE_STORMFW_VERSION_LENGTH      32
49 #define BXE_BUS_INFO_LENGTH             32
50 
51 struct bxe_drvinfo {
52     char drv_name[BXE_DRV_NAME_LENGTH];
53     char drv_version[BXE_DRV_VERSION_LENGTH];
54     char mfw_version[BXE_MFW_VERSION_LENGTH];
55     char stormfw_version[BXE_STORMFW_VERSION_LENGTH];
56     uint32_t eeprom_dump_len; /* in bytes */
57     uint32_t reg_dump_len; /* in bytes */
58     char bus_info[BXE_BUS_INFO_LENGTH];
59 };
60 typedef struct bxe_drvinfo bxe_drvinfo_t;
61 
62 struct bxe_dev_setting {
63 
64     uint32_t supported;  /* Features this interface supports */
65     uint32_t advertising;/* Features this interface advertises */
66     uint32_t speed;      /* The forced speed, 10Mb, 100Mb, gigabit */
67     uint32_t duplex;     /* Duplex, half or full */
68     uint32_t port;       /* Which connector port */
69     uint32_t phy_address;/* port number*/
70     uint32_t autoneg;    /* Enable or disable autonegotiation */
71 };
72 typedef struct bxe_dev_setting bxe_dev_setting_t;
73 
74 struct bxe_get_regs {
75     void *reg_buf;
76     uint32_t reg_buf_len;
77 };
78 typedef struct bxe_get_regs bxe_get_regs_t;
79 
80 #define BXE_EEPROM_MAX_DATA_LEN   524288
81 
82 struct bxe_eeprom {
83     uint32_t eeprom_cmd;
84 #define BXE_EEPROM_CMD_SET_EEPROM       0x01
85 #define BXE_EEPROM_CMD_GET_EEPROM       0x02
86 
87     void *eeprom_data;
88     uint32_t eeprom_offset;
89     uint32_t eeprom_data_len;
90     uint32_t eeprom_magic;
91 };
92 typedef struct bxe_eeprom bxe_eeprom_t;
93 
94 struct bxe_reg_rdw {
95     uint32_t reg_cmd;
96 #define BXE_READ_REG_CMD                0x01
97 #define BXE_WRITE_REG_CMD               0x02
98 
99     uint32_t reg_id;
100     uint32_t reg_val;
101     uint32_t reg_access_type;
102 #define BXE_REG_ACCESS_DIRECT           0x01
103 #define BXE_REG_ACCESS_INDIRECT         0x02
104 };
105 
106 typedef struct bxe_reg_rdw bxe_reg_rdw_t;
107 
108 struct bxe_pcicfg_rdw {
109     uint32_t cfg_cmd;
110 #define BXE_READ_PCICFG                 0x01
111 #define BXE_WRITE_PCICFG                0x01
112     uint32_t cfg_id;
113     uint32_t cfg_val;
114     uint32_t cfg_width;
115 };
116 
117 typedef struct bxe_pcicfg_rdw bxe_pcicfg_rdw_t;
118 
119 struct bxe_perm_mac_addr {
120     char mac_addr_str[32];
121 };
122 
123 typedef struct bxe_perm_mac_addr bxe_perm_mac_addr_t;
124 
125 
126 /*
127  * Read grcdump size
128  */
129 #define BXE_GRC_DUMP_SIZE     _IOWR('e', 1, bxe_grcdump_t)
130 
131 /*
132  * Read grcdump
133  */
134 #define BXE_GRC_DUMP          _IOWR('e', 2, bxe_grcdump_t)
135 
136 /*
137  * Read driver info
138  */
139 #define BXE_DRV_INFO          _IOR('e', 3, bxe_drvinfo_t)
140 
141 /*
142  * Read Device Setting
143  */
144 #define BXE_DEV_SETTING       _IOR('e', 4, bxe_dev_setting_t)
145 
146 /*
147  * Get Registers
148  */
149 #define BXE_GET_REGS          _IOR('e', 5, bxe_get_regs_t)
150 
151 /*
152  * Get/Set EEPROM
153  */
154 #define BXE_EEPROM            _IOWR('e', 6, bxe_eeprom_t)
155 
156 /*
157  * read/write a register
158  */
159 #define BXE_RDW_REG           _IOWR('e', 7, bxe_reg_rdw_t)
160 
161 /*
162  * read/write PCIcfg
163  */
164 #define BXE_RDW_PCICFG        _IOWR('e', 8, bxe_reg_rdw_t)
165 
166 /*
167  * get permanent mac address
168  */
169 
170 #define BXE_MAC_ADDR          _IOWR('e', 9, bxe_perm_mac_addr_t)
171 
172 
173 #endif /* #ifndef _QLNX_IOCTL_H_ */
174