xref: /freebsd/sys/dev/bnxt/bnxt_mgmt.h (revision dbd5678d)
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 
45 #define BNXT_MGMT_MAX_HWRM_REQ_LENGTH		HWRM_MAX_REQ_LEN
46 #define BNXT_MGMT_MAX_HWRM_RESP_LENGTH		(512)
47 
48 struct bnxt_nic_info {
49 #define BNXT_MAX_STR 64
50 	char dev_name[BNXT_MAX_STR];
51 	char driver_version[BNXT_MAX_STR];
52 	char driver_name[BNXT_MAX_STR];
53 	char device_serial_number[64];
54 	uint32_t mtu;
55 	uint8_t mac[ETHER_ADDR_LEN];
56 	uint32_t pci_link_speed;
57 	uint32_t pci_link_width;
58 	uint32_t rsvd[4];
59 } __packed;
60 
61 struct bnxt_pci_info {
62         uint16_t domain_no;
63         uint16_t bus_no;
64         uint16_t device_no;
65         uint16_t function_no;
66         uint16_t vendor_id;
67         uint16_t device_id;
68         uint16_t sub_system_vendor_id;
69         uint16_t sub_system_device_id;
70         uint16_t revision;
71         uint32_t chip_rev_id;
72 	uint32_t rsvd[2];
73 } __packed;
74 
75 struct bnxt_dev_info {
76         struct bnxt_nic_info nic_info;
77         struct bnxt_pci_info pci_info;
78 } __packed;
79 
80 struct dma_info {
81         uint64_t data;
82         uint32_t length;
83         uint16_t offset;
84         uint8_t read_or_write;
85         uint8_t unused;
86 };
87 
88 struct bnxt_mgmt_fw_msg {
89         uint64_t usr_req;
90         uint64_t usr_resp;
91         uint32_t len_req;
92         uint32_t len_resp;
93         uint32_t timeout;
94         uint32_t num_dma_indications;
95         struct dma_info dma[0];
96 };
97 
98 struct bnxt_mgmt_generic_msg {
99         uint8_t key;
100 #define BNXT_LFC_KEY_DOMAIN_NO  1
101         uint8_t reserved[3];
102         uint32_t value;
103 };
104 
105 enum bnxt_mgmt_req_type {
106         BNXT_MGMT_NVM_GET_VAR_REQ = 1,
107         BNXT_MGMT_NVM_SET_VAR_REQ,
108         BNXT_MGMT_NVM_FLUSH_REQ,
109         BNXT_MGMT_GENERIC_HWRM_REQ,
110 };
111 
112 struct bnxt_mgmt_req_hdr {
113         uint32_t ver;
114 	uint32_t domain;
115         uint32_t bus;
116         uint32_t devfn;
117         enum bnxt_mgmt_req_type req_type;
118 };
119 
120 struct bnxt_mgmt_req {
121         struct bnxt_mgmt_req_hdr hdr;
122         union {
123             uint64_t hreq;
124         } req;
125 };
126 
127