.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 2015-2017 Netronome Systems, Inc. |
---|
3 | | - * |
---|
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. |
---|
8 | | - * |
---|
9 | | - * The BSD 2-Clause License: |
---|
10 | | - * |
---|
11 | | - * Redistribution and use in source and binary forms, with or |
---|
12 | | - * without modification, are permitted provided that the following |
---|
13 | | - * conditions are met: |
---|
14 | | - * |
---|
15 | | - * 1. Redistributions of source code must retain the above |
---|
16 | | - * copyright notice, this list of conditions and the following |
---|
17 | | - * disclaimer. |
---|
18 | | - * |
---|
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. |
---|
23 | | - * |
---|
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 |
---|
31 | | - * SOFTWARE. |
---|
32 | | - */ |
---|
| 1 | +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) |
---|
| 2 | +/* Copyright (C) 2015-2018 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | /* |
---|
35 | 5 | * nfp_net_main.c |
---|
.. | .. |
---|
146 | 116 | n_rx_rings = readl(ctrl_bar + NFP_NET_CFG_MAX_RXRINGS); |
---|
147 | 117 | |
---|
148 | 118 | /* Allocate and initialise the vNIC */ |
---|
149 | | - nn = nfp_net_alloc(pf->pdev, needs_netdev, n_tx_rings, n_rx_rings); |
---|
| 119 | + nn = nfp_net_alloc(pf->pdev, ctrl_bar, needs_netdev, |
---|
| 120 | + n_tx_rings, n_rx_rings); |
---|
150 | 121 | if (IS_ERR(nn)) |
---|
151 | 122 | return nn; |
---|
152 | 123 | |
---|
153 | 124 | nn->app = pf->app; |
---|
154 | 125 | nfp_net_get_fw_version(&nn->fw_ver, ctrl_bar); |
---|
155 | | - nn->dp.ctrl_bar = ctrl_bar; |
---|
156 | 126 | nn->tx_bar = qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ; |
---|
157 | 127 | nn->rx_bar = qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ; |
---|
158 | 128 | nn->dp.is_vf = 0; |
---|
.. | .. |
---|
180 | 150 | |
---|
181 | 151 | nn->id = id; |
---|
182 | 152 | |
---|
183 | | - err = nfp_net_init(nn); |
---|
184 | | - if (err) |
---|
185 | | - return err; |
---|
186 | | - |
---|
187 | | - nfp_net_debugfs_vnic_add(nn, pf->ddir); |
---|
188 | | - |
---|
189 | 153 | if (nn->port) { |
---|
190 | 154 | err = nfp_devlink_port_register(pf->app, nn->port); |
---|
191 | 155 | if (err) |
---|
192 | | - goto err_dfs_clean; |
---|
| 156 | + return err; |
---|
193 | 157 | } |
---|
| 158 | + |
---|
| 159 | + err = nfp_net_init(nn); |
---|
| 160 | + if (err) |
---|
| 161 | + goto err_devlink_port_clean; |
---|
| 162 | + |
---|
| 163 | + nfp_net_debugfs_vnic_add(nn, pf->ddir); |
---|
| 164 | + |
---|
| 165 | + if (nn->port) |
---|
| 166 | + nfp_devlink_port_type_eth_set(nn->port); |
---|
194 | 167 | |
---|
195 | 168 | nfp_net_info(nn); |
---|
196 | 169 | |
---|
197 | 170 | if (nfp_net_is_data_vnic(nn)) { |
---|
198 | 171 | err = nfp_app_vnic_init(pf->app, nn); |
---|
199 | 172 | if (err) |
---|
200 | | - goto err_devlink_port_clean; |
---|
| 173 | + goto err_devlink_port_type_clean; |
---|
201 | 174 | } |
---|
202 | 175 | |
---|
203 | 176 | return 0; |
---|
204 | 177 | |
---|
| 178 | +err_devlink_port_type_clean: |
---|
| 179 | + if (nn->port) |
---|
| 180 | + nfp_devlink_port_type_clear(nn->port); |
---|
| 181 | + nfp_net_debugfs_dir_clean(&nn->debugfs_dir); |
---|
| 182 | + nfp_net_clean(nn); |
---|
205 | 183 | err_devlink_port_clean: |
---|
206 | 184 | if (nn->port) |
---|
207 | 185 | nfp_devlink_port_unregister(nn->port); |
---|
208 | | -err_dfs_clean: |
---|
209 | | - nfp_net_debugfs_dir_clean(&nn->debugfs_dir); |
---|
210 | | - nfp_net_clean(nn); |
---|
211 | 186 | return err; |
---|
212 | 187 | } |
---|
213 | 188 | |
---|
.. | .. |
---|
230 | 205 | ctrl_bar += NFP_PF_CSR_SLICE_SIZE; |
---|
231 | 206 | |
---|
232 | 207 | /* Kill the vNIC if app init marked it as invalid */ |
---|
233 | | - if (nn->port && nn->port->type == NFP_PORT_INVALID) { |
---|
| 208 | + if (nn->port && nn->port->type == NFP_PORT_INVALID) |
---|
234 | 209 | nfp_net_pf_free_vnic(pf, nn); |
---|
235 | | - continue; |
---|
236 | | - } |
---|
237 | 210 | } |
---|
238 | 211 | |
---|
239 | 212 | if (list_empty(&pf->vnics)) |
---|
.. | .. |
---|
251 | 224 | if (nfp_net_is_data_vnic(nn)) |
---|
252 | 225 | nfp_app_vnic_clean(pf->app, nn); |
---|
253 | 226 | if (nn->port) |
---|
254 | | - nfp_devlink_port_unregister(nn->port); |
---|
| 227 | + nfp_devlink_port_type_clear(nn->port); |
---|
255 | 228 | nfp_net_debugfs_dir_clean(&nn->debugfs_dir); |
---|
256 | 229 | nfp_net_clean(nn); |
---|
| 230 | + if (nn->port) |
---|
| 231 | + nfp_devlink_port_unregister(nn->port); |
---|
257 | 232 | } |
---|
258 | 233 | |
---|
259 | 234 | static int nfp_net_pf_alloc_irqs(struct nfp_pf *pf) |
---|
.. | .. |
---|
470 | 445 | |
---|
471 | 446 | static int nfp_net_pci_map_mem(struct nfp_pf *pf) |
---|
472 | 447 | { |
---|
| 448 | + u32 min_size, cpp_id; |
---|
473 | 449 | u8 __iomem *mem; |
---|
474 | | - u32 min_size; |
---|
475 | 450 | int err; |
---|
476 | 451 | |
---|
477 | 452 | min_size = pf->max_data_vnics * NFP_PF_CSR_SLICE_SIZE; |
---|
.. | .. |
---|
519 | 494 | pf->vfcfg_tbl2 = NULL; |
---|
520 | 495 | } |
---|
521 | 496 | |
---|
522 | | - mem = nfp_cpp_map_area(pf->cpp, "net.qc", 0, 0, |
---|
523 | | - NFP_PCIE_QUEUE(0), NFP_QCP_QUEUE_AREA_SZ, |
---|
524 | | - &pf->qc_area); |
---|
| 497 | + cpp_id = NFP_CPP_ISLAND_ID(0, NFP_CPP_ACTION_RW, 0, 0); |
---|
| 498 | + mem = nfp_cpp_map_area(pf->cpp, "net.qc", cpp_id, NFP_PCIE_QUEUE(0), |
---|
| 499 | + NFP_QCP_QUEUE_AREA_SZ, &pf->qc_area); |
---|
525 | 500 | if (IS_ERR(mem)) { |
---|
526 | 501 | nfp_err(pf->cpp, "Failed to map Queue Controller area.\n"); |
---|
527 | 502 | err = PTR_ERR(mem); |
---|
.. | .. |
---|
734 | 709 | if (err) |
---|
735 | 710 | goto err_devlink_unreg; |
---|
736 | 711 | |
---|
| 712 | + err = nfp_devlink_params_register(pf); |
---|
| 713 | + if (err) |
---|
| 714 | + goto err_shared_buf_unreg; |
---|
| 715 | + |
---|
737 | 716 | mutex_lock(&pf->lock); |
---|
738 | 717 | pf->ddir = nfp_net_debugfs_device_add(pf->pdev); |
---|
739 | 718 | |
---|
.. | .. |
---|
767 | 746 | err_clean_ddir: |
---|
768 | 747 | nfp_net_debugfs_dir_clean(&pf->ddir); |
---|
769 | 748 | mutex_unlock(&pf->lock); |
---|
| 749 | + nfp_devlink_params_unregister(pf); |
---|
| 750 | +err_shared_buf_unreg: |
---|
770 | 751 | nfp_shared_buf_unregister(pf); |
---|
771 | 752 | err_devlink_unreg: |
---|
772 | 753 | cancel_work_sync(&pf->port_refresh_work); |
---|
.. | .. |
---|
796 | 777 | |
---|
797 | 778 | mutex_unlock(&pf->lock); |
---|
798 | 779 | |
---|
| 780 | + nfp_devlink_params_unregister(pf); |
---|
799 | 781 | nfp_shared_buf_unregister(pf); |
---|
800 | 782 | devlink_unregister(priv_to_devlink(pf)); |
---|
801 | 783 | |
---|