.. | .. |
---|
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_cppcore.c |
---|
.. | .. |
---|
75 | 45 | * @interface: chip interface id we are using to reach it |
---|
76 | 46 | * @serial: chip serial number |
---|
77 | 47 | * @imb_cat_table: CPP Mapping Table |
---|
| 48 | + * @mu_locality_lsb: MU access type bit offset |
---|
78 | 49 | * |
---|
79 | 50 | * Following fields use explicit locking: |
---|
80 | 51 | * @resource_list: NFP CPP resource list |
---|
.. | .. |
---|
100 | 71 | wait_queue_head_t waitq; |
---|
101 | 72 | |
---|
102 | 73 | u32 imb_cat_table[16]; |
---|
| 74 | + unsigned int mu_locality_lsb; |
---|
103 | 75 | |
---|
104 | 76 | struct mutex area_cache_mutex; |
---|
105 | 77 | struct list_head area_cache_list; |
---|
.. | .. |
---|
264 | 236 | { |
---|
265 | 237 | *serial = &cpp->serial[0]; |
---|
266 | 238 | 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; |
---|
267 | 267 | } |
---|
268 | 268 | |
---|
269 | 269 | /** |
---|
.. | .. |
---|
874 | 874 | } |
---|
875 | 875 | |
---|
876 | 876 | /* Adjust the start address to be cache size aligned */ |
---|
877 | | - cache->id = id; |
---|
878 | 877 | cache->addr = addr & ~(u64)(cache->size - 1); |
---|
879 | 878 | |
---|
880 | 879 | /* Re-init to the new ID and address */ |
---|
.. | .. |
---|
893 | 892 | mutex_unlock(&cpp->area_cache_mutex); |
---|
894 | 893 | return NULL; |
---|
895 | 894 | } |
---|
| 895 | + |
---|
| 896 | + cache->id = id; |
---|
896 | 897 | |
---|
897 | 898 | exit: |
---|
898 | 899 | /* Adjust offset */ |
---|
.. | .. |
---|
1243 | 1244 | nfp_cpp_readl(cpp, arm, NFP_ARM_GCSR + NFP_ARM_GCSR_SOFTMODEL3, |
---|
1244 | 1245 | &mask[1]); |
---|
1245 | 1246 | |
---|
| 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 | + |
---|
1246 | 1253 | dev_info(cpp->dev.parent, "Model: 0x%08x, SN: %pM, Ifc: 0x%04x\n", |
---|
1247 | 1254 | nfp_cpp_model(cpp), cpp->serial, nfp_cpp_interface(cpp)); |
---|
1248 | 1255 | |
---|