hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.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_cppcore.c
....@@ -75,6 +45,7 @@
7545 * @interface: chip interface id we are using to reach it
7646 * @serial: chip serial number
7747 * @imb_cat_table: CPP Mapping Table
48
+ * @mu_locality_lsb: MU access type bit offset
7849 *
7950 * Following fields use explicit locking:
8051 * @resource_list: NFP CPP resource list
....@@ -100,6 +71,7 @@
10071 wait_queue_head_t waitq;
10172
10273 u32 imb_cat_table[16];
74
+ unsigned int mu_locality_lsb;
10375
10476 struct mutex area_cache_mutex;
10577 struct list_head area_cache_list;
....@@ -264,6 +236,34 @@
264236 {
265237 *serial = &cpp->serial[0];
266238 return sizeof(cpp->serial);
239
+}
240
+
241
+#define NFP_IMB_TGTADDRESSMODECFG_MODE_of(_x) (((_x) >> 13) & 0x7)
242
+#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE BIT(12)
243
+#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_32_BIT 0
244
+#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_40_BIT BIT(12)
245
+
246
+static int nfp_cpp_set_mu_locality_lsb(struct nfp_cpp *cpp)
247
+{
248
+ unsigned int mode, addr40;
249
+ u32 imbcppat;
250
+ int res;
251
+
252
+ imbcppat = cpp->imb_cat_table[NFP_CPP_TARGET_MU];
253
+ mode = NFP_IMB_TGTADDRESSMODECFG_MODE_of(imbcppat);
254
+ addr40 = !!(imbcppat & NFP_IMB_TGTADDRESSMODECFG_ADDRMODE);
255
+
256
+ res = nfp_cppat_mu_locality_lsb(mode, addr40);
257
+ if (res < 0)
258
+ return res;
259
+ cpp->mu_locality_lsb = res;
260
+
261
+ return 0;
262
+}
263
+
264
+unsigned int nfp_cpp_mu_locality_lsb(struct nfp_cpp *cpp)
265
+{
266
+ return cpp->mu_locality_lsb;
267267 }
268268
269269 /**
....@@ -874,7 +874,6 @@
874874 }
875875
876876 /* Adjust the start address to be cache size aligned */
877
- cache->id = id;
878877 cache->addr = addr & ~(u64)(cache->size - 1);
879878
880879 /* Re-init to the new ID and address */
....@@ -893,6 +892,8 @@
893892 mutex_unlock(&cpp->area_cache_mutex);
894893 return NULL;
895894 }
895
+
896
+ cache->id = id;
896897
897898 exit:
898899 /* Adjust offset */
....@@ -1243,6 +1244,12 @@
12431244 nfp_cpp_readl(cpp, arm, NFP_ARM_GCSR + NFP_ARM_GCSR_SOFTMODEL3,
12441245 &mask[1]);
12451246
1247
+ err = nfp_cpp_set_mu_locality_lsb(cpp);
1248
+ if (err < 0) {
1249
+ dev_err(parent, "Can't calculate MU locality bit offset\n");
1250
+ goto err_out;
1251
+ }
1252
+
12461253 dev_info(cpp->dev.parent, "Model: 0x%08x, SN: %pM, Ifc: 0x%04x\n",
12471254 nfp_cpp_model(cpp), cpp->serial, nfp_cpp_interface(cpp));
12481255