xref: /freebsd/sys/dev/bnxt/bnxt_en/bnxt_mgmt.h (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1 /*
2  * Broadcom NetXtreme-C/E network driver.
3  *
4  * Copyright (c) 2022 Broadcom, All Rights Reserved.
5  * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "bnxt.h"
30 #include <sys/types.h>
31 #include <sys/systm.h>
32 #include <sys/param.h>
33 #include <sys/module.h>
34 #include <sys/kernel.h>
35 #include <sys/conf.h>
36 #include <sys/uio.h>
37 #include <sys/malloc.h>
38 
39 
40 #define	DRIVER_NAME				"if_bnxt"
41 
42 #define	BNXT_MGMT_OPCODE_GET_DEV_INFO		0x80000000
43 #define	BNXT_MGMT_OPCODE_PASSTHROUGH_HWRM	0x80000001
44 #define	BNXT_MGMT_OPCODE_DCB_OPS		0x80000002
45 
46 #define BNXT_MGMT_MAX_HWRM_REQ_LENGTH		HWRM_MAX_REQ_LEN
47 #define BNXT_MGMT_MAX_HWRM_RESP_LENGTH		(512)
48 
49 struct bnxt_nic_info {
50 #define BNXT_MAX_STR 64
51 	char dev_name[BNXT_MAX_STR];
52 	char driver_version[BNXT_MAX_STR];
53 	char driver_name[BNXT_MAX_STR];
54 	char device_serial_number[64];
55 	uint32_t mtu;
56 	uint8_t mac[ETHER_ADDR_LEN];
57 	uint32_t pci_link_speed;
58 	uint32_t pci_link_width;
59 	uint32_t rsvd[4];
60 } __packed;
61 
62 struct bnxt_pci_info {
63         uint16_t domain_no;
64         uint16_t bus_no;
65         uint16_t device_no;
66         uint16_t function_no;
67         uint16_t vendor_id;
68         uint16_t device_id;
69         uint16_t sub_system_vendor_id;
70         uint16_t sub_system_device_id;
71         uint16_t revision;
72         uint32_t chip_rev_id;
73 	uint32_t rsvd[2];
74 } __packed;
75 
76 struct bnxt_dev_info {
77         struct bnxt_nic_info nic_info;
78         struct bnxt_pci_info pci_info;
79 } __packed;
80 
81 struct dma_info {
82         uint64_t data;
83         uint32_t length;
84         uint16_t offset;
85         uint8_t read_or_write;
86         uint8_t unused;
87 };
88 
89 struct bnxt_mgmt_fw_msg {
90         uint64_t usr_req;
91         uint64_t usr_resp;
92         uint32_t len_req;
93         uint32_t len_resp;
94         uint32_t timeout;
95         uint32_t num_dma_indications;
96         struct dma_info dma[0];
97 };
98 
99 struct bnxt_mgmt_generic_msg {
100         uint8_t key;
101 #define BNXT_LFC_KEY_DOMAIN_NO  1
102         uint8_t reserved[3];
103         uint32_t value;
104 };
105 
106 enum bnxt_mgmt_req_type {
107         BNXT_MGMT_NVM_GET_VAR_REQ = 1,
108         BNXT_MGMT_NVM_SET_VAR_REQ,
109         BNXT_MGMT_NVM_FLUSH_REQ,
110         BNXT_MGMT_GENERIC_HWRM_REQ,
111 };
112 
113 struct bnxt_mgmt_req_hdr {
114         uint32_t ver;
115 	uint32_t domain;
116         uint32_t bus;
117         uint32_t devfn;
118         enum bnxt_mgmt_req_type req_type;
119 };
120 
121 struct bnxt_mgmt_req {
122 	struct bnxt_mgmt_req_hdr hdr;
123 	union {
124 		uint64_t hreq;
125 	} req;
126 };
127 
128 struct bnxt_mgmt_app_tlv {
129 	uint32_t num_app;
130 	struct bnxt_dcb_app app[128];
131 } __attribute__ ((__packed__));
132 
133 struct bnxt_mgmt_dcb {
134 	struct bnxt_mgmt_req_hdr hdr;
135 #define BNXT_MGMT_DCB_GET_ETS	0x1
136 #define BNXT_MGMT_DCB_SET_ETS	0x2
137 #define BNXT_MGMT_DCB_GET_PFC	0x3
138 #define BNXT_MGMT_DCB_SET_PFC	0x4
139 #define BNXT_MGMT_DCB_SET_APP	0x5
140 #define BNXT_MGMT_DCB_DEL_APP	0x6
141 #define BNXT_MGMT_DCB_LIST_APP	0x7
142 #define BNXT_MGMT_DCB_MAX	BNXT_MGMT_DCB_LIST_APP
143 	uint32_t op;
144 	union {
145 		struct bnxt_ieee_ets ets;
146 		struct bnxt_ieee_pfc pfc;
147 		struct bnxt_mgmt_app_tlv app_tlv;
148 	} req;
149 } __attribute__ ((__packed__));
150