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);
52 enum nfp_eth_interface {
53 NFP_INTERFACE_NONE = 0,
54 NFP_INTERFACE_SFP = 1,
55 NFP_INTERFACE_SFPP = 10,
56 NFP_INTERFACE_SFP28 = 28,
57 NFP_INTERFACE_QSFP = 40,
58 NFP_INTERFACE_CXP = 100,
59 NFP_INTERFACE_QSFP28 = 112,
63 NFP_MEDIA_DAC_PASSIVE = 0,
71 NFP_ANEG_25G_CONSORTIUM,
77 * struct nfp_eth_table - ETH table information
78 * @count: number of table entries
79 * @max_index: max of @index fields of all @ports
80 * @ports: table of ports
82 * @eth_index: port index according to legacy ethX numbering
83 * @index: chip-wide first channel index
85 * @base: first channel index (within NBI)
86 * @lanes: number of channels
87 * @speed: interface speed (in Mbps)
88 * @interface: interface (module) plugged in
89 * @media: media type of the @interface
90 * @aneg: auto negotiation mode
91 * @mac_addr: interface MAC address
92 * @label_port: port id
93 * @label_subport: id of interface within port (for split ports)
94 * @enabled: is enabled?
95 * @tx_enabled: is TX enabled?
96 * @rx_enabled: is RX enabled?
97 * @override_changed: is media reconfig pending?
99 * @port_type: one of %PORT_* defines for ethtool
100 * @port_lanes: total number of lanes on the port (sum of lanes of all subports)
101 * @is_split: is interface part of a split port
103 struct nfp_eth_table {
105 unsigned int max_index;
106 struct nfp_eth_table_port {
107 unsigned int eth_index;
114 unsigned int interface;
115 enum nfp_eth_media media;
117 enum nfp_eth_aneg aneg;
119 u8 mac_addr[ETH_ALEN];
128 bool override_changed;
130 /* Computed fields */
133 unsigned int port_lanes;
139 struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);
140 struct nfp_eth_table *
141 __nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp);
143 int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, unsigned int idx, bool enable);
144 int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx,
147 struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx);
148 int nfp_eth_config_commit_end(struct nfp_nsp *nsp);
149 void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp);
151 int __nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode);
152 int __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed);
153 int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes);
156 * struct nfp_nsp_identify - NSP static information
157 * @version: opaque version string
158 * @flags: version flags
159 * @br_primary: branch id of primary bootloader
160 * @br_secondary: branch id of secondary bootloader
161 * @br_nsp: branch id of NSP
162 * @primary: version of primarary bootloader
163 * @secondary: version id of secondary bootloader
164 * @nsp: version id of NSP
165 * @sensor_mask: mask of present sensors available on NIC
167 struct nfp_nsp_identify {
179 struct nfp_nsp_identify *__nfp_nsp_identify(struct nfp_nsp *nsp);
181 enum nfp_nsp_sensor_id {
182 NFP_SENSOR_CHIP_TEMPERATURE,
183 NFP_SENSOR_ASSEMBLY_POWER,
184 NFP_SENSOR_ASSEMBLY_12V_POWER,
185 NFP_SENSOR_ASSEMBLY_3V3_POWER,
188 int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id,