2 * Copyright (C) 2015-2017 Netronome Systems, Inc.
4 * This software is dual licensed under the GNU General License Version 2,
5 * June 1991 as shown in the file COPYING in the top-level directory of this
6 * source tree or the BSD 2-Clause License provided below. You have the
7 * option to license this software under the complete terms of either license.
9 * The BSD 2-Clause License:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * 1. Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * 2. Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 #include <linux/types.h>
38 #include <linux/if_ether.h>
44 struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);
45 void nfp_nsp_close(struct nfp_nsp *state);
46 u16 nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
47 u16 nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
48 int nfp_nsp_wait(struct nfp_nsp *state);
49 int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
50 int nfp_nsp_load_fw(struct nfp_nsp *state, const struct firmware *fw);
51 int nfp_nsp_write_flash(struct nfp_nsp *state, const struct firmware *fw);
52 int nfp_nsp_mac_reinit(struct nfp_nsp *state);
54 static inline bool nfp_nsp_has_mac_reinit(struct nfp_nsp *state)
56 return nfp_nsp_get_abi_ver_minor(state) > 20;
59 enum nfp_eth_interface {
60 NFP_INTERFACE_NONE = 0,
61 NFP_INTERFACE_SFP = 1,
62 NFP_INTERFACE_SFPP = 10,
63 NFP_INTERFACE_SFP28 = 28,
64 NFP_INTERFACE_QSFP = 40,
65 NFP_INTERFACE_CXP = 100,
66 NFP_INTERFACE_QSFP28 = 112,
70 NFP_MEDIA_DAC_PASSIVE = 0,
78 NFP_ANEG_25G_CONSORTIUM,
86 NFP_FEC_REED_SOLOMON_BIT,
90 #define NFP_FEC_AUTO BIT(NFP_FEC_AUTO_BIT)
91 #define NFP_FEC_BASER BIT(NFP_FEC_BASER_BIT)
92 #define NFP_FEC_REED_SOLOMON BIT(NFP_FEC_REED_SOLOMON_BIT)
93 #define NFP_FEC_DISABLED BIT(NFP_FEC_DISABLED_BIT)
96 * struct nfp_eth_table - ETH table information
97 * @count: number of table entries
98 * @max_index: max of @index fields of all @ports
99 * @ports: table of ports
101 * @ports.eth_index: port index according to legacy ethX numbering
102 * @ports.index: chip-wide first channel index
103 * @ports.nbi: NBI index
104 * @ports.base: first channel index (within NBI)
105 * @ports.lanes: number of channels
106 * @ports.speed: interface speed (in Mbps)
107 * @ports.interface: interface (module) plugged in
108 * @ports.media: media type of the @interface
109 * @ports.fec: forward error correction mode
110 * @ports.aneg: auto negotiation mode
111 * @ports.mac_addr: interface MAC address
112 * @ports.label_port: port id
113 * @ports.label_subport: id of interface within port (for split ports)
114 * @ports.enabled: is enabled?
115 * @ports.tx_enabled: is TX enabled?
116 * @ports.rx_enabled: is RX enabled?
117 * @ports.override_changed: is media reconfig pending?
119 * @ports.port_type: one of %PORT_* defines for ethtool
120 * @ports.port_lanes: total number of lanes on the port (sum of lanes of all
122 * @ports.is_split: is interface part of a split port
123 * @ports.fec_modes_supported: bitmap of FEC modes supported
125 struct nfp_eth_table {
127 unsigned int max_index;
128 struct nfp_eth_table_port {
129 unsigned int eth_index;
136 unsigned int interface;
137 enum nfp_eth_media media;
139 enum nfp_eth_fec fec;
140 enum nfp_eth_aneg aneg;
142 u8 mac_addr[ETH_ALEN];
151 bool override_changed;
153 /* Computed fields */
156 unsigned int port_lanes;
160 unsigned int fec_modes_supported;
164 struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);
165 struct nfp_eth_table *
166 __nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp);
168 int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, unsigned int idx, bool enable);
169 int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx,
172 nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode);
174 static inline bool nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
176 return !!eth_port->fec_modes_supported;
179 static inline unsigned int
180 nfp_eth_supported_fec_modes(struct nfp_eth_table_port *eth_port)
182 return eth_port->fec_modes_supported;
185 struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx);
186 int nfp_eth_config_commit_end(struct nfp_nsp *nsp);
187 void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp);
189 int __nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode);
190 int __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed);
191 int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes);
194 * struct nfp_nsp_identify - NSP static information
195 * @version: opaque version string
196 * @flags: version flags
197 * @br_primary: branch id of primary bootloader
198 * @br_secondary: branch id of secondary bootloader
199 * @br_nsp: branch id of NSP
200 * @primary: version of primarary bootloader
201 * @secondary: version id of secondary bootloader
202 * @nsp: version id of NSP
203 * @sensor_mask: mask of present sensors available on NIC
205 struct nfp_nsp_identify {
217 struct nfp_nsp_identify *__nfp_nsp_identify(struct nfp_nsp *nsp);
219 enum nfp_nsp_sensor_id {
220 NFP_SENSOR_CHIP_TEMPERATURE,
221 NFP_SENSOR_ASSEMBLY_POWER,
222 NFP_SENSOR_ASSEMBLY_12V_POWER,
223 NFP_SENSOR_ASSEMBLY_3V3_POWER,
226 int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id,