forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/netronome/nfp/nfp_netvf_main.c
....@@ -1,35 +1,5 @@
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. */
333
344 /*
355 * nfp_netvf_main.c
....@@ -136,7 +106,7 @@
136106 * first NFP_NET_CFG_BAR_SZ of the BAR. This keeps the code
137107 * the identical for PF and VF drivers.
138108 */
139
- ctrl_bar = ioremap_nocache(pci_resource_start(pdev, NFP_NET_CTRL_BAR),
109
+ ctrl_bar = ioremap(pci_resource_start(pdev, NFP_NET_CTRL_BAR),
140110 NFP_NET_CFG_BAR_SZ);
141111 if (!ctrl_bar) {
142112 dev_err(&pdev->dev,
....@@ -202,7 +172,7 @@
202172 rx_bar_off = NFP_PCIE_QUEUE(startq);
203173
204174 /* Allocate and initialise the netdev */
205
- nn = nfp_net_alloc(pdev, true, max_tx_rings, max_rx_rings);
175
+ nn = nfp_net_alloc(pdev, ctrl_bar, true, max_tx_rings, max_rx_rings);
206176 if (IS_ERR(nn)) {
207177 err = PTR_ERR(nn);
208178 goto err_ctrl_unmap;
....@@ -210,7 +180,6 @@
210180 vf->nn = nn;
211181
212182 nn->fw_ver = fw_ver;
213
- nn->dp.ctrl_bar = ctrl_bar;
214183 nn->dp.is_vf = 1;
215184 nn->stride_tx = stride;
216185 nn->stride_rx = stride;
....@@ -231,7 +200,7 @@
231200 bar_sz = (rx_bar_off + rx_bar_sz) - bar_off;
232201
233202 map_addr = pci_resource_start(pdev, tx_bar_no) + bar_off;
234
- vf->q_bar = ioremap_nocache(map_addr, bar_sz);
203
+ vf->q_bar = ioremap(map_addr, bar_sz);
235204 if (!vf->q_bar) {
236205 nn_err(nn, "Failed to map resource %d\n", tx_bar_no);
237206 err = -EIO;
....@@ -247,7 +216,7 @@
247216
248217 /* TX queues */
249218 map_addr = pci_resource_start(pdev, tx_bar_no) + tx_bar_off;
250
- nn->tx_bar = ioremap_nocache(map_addr, tx_bar_sz);
219
+ nn->tx_bar = ioremap(map_addr, tx_bar_sz);
251220 if (!nn->tx_bar) {
252221 nn_err(nn, "Failed to map resource %d\n", tx_bar_no);
253222 err = -EIO;
....@@ -256,7 +225,7 @@
256225
257226 /* RX queues */
258227 map_addr = pci_resource_start(pdev, rx_bar_no) + rx_bar_off;
259
- nn->rx_bar = ioremap_nocache(map_addr, rx_bar_sz);
228
+ nn->rx_bar = ioremap(map_addr, rx_bar_sz);
260229 if (!nn->rx_bar) {
261230 nn_err(nn, "Failed to map resource %d\n", rx_bar_no);
262231 err = -EIO;
....@@ -313,8 +282,14 @@
313282
314283 static void nfp_netvf_pci_remove(struct pci_dev *pdev)
315284 {
316
- struct nfp_net_vf *vf = pci_get_drvdata(pdev);
317
- struct nfp_net *nn = vf->nn;
285
+ struct nfp_net_vf *vf;
286
+ struct nfp_net *nn;
287
+
288
+ vf = pci_get_drvdata(pdev);
289
+ if (!vf)
290
+ return;
291
+
292
+ nn = vf->nn;
318293
319294 /* Note, the order is slightly different from above as we need
320295 * to keep the nn pointer around till we have freed everything.
....@@ -348,4 +323,5 @@
348323 .id_table = nfp_netvf_pci_device_ids,
349324 .probe = nfp_netvf_pci_probe,
350325 .remove = nfp_netvf_pci_remove,
326
+ .shutdown = nfp_netvf_pci_remove,
351327 };