.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 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) 2017-2019 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | #include <linux/bitfield.h> |
---|
35 | 5 | #include <linux/errno.h> |
---|
.. | .. |
---|
176 | 146 | "spoofchk"); |
---|
177 | 147 | } |
---|
178 | 148 | |
---|
| 149 | +int nfp_app_set_vf_trust(struct net_device *netdev, int vf, bool enable) |
---|
| 150 | +{ |
---|
| 151 | + struct nfp_app *app = nfp_app_from_netdev(netdev); |
---|
| 152 | + unsigned int vf_offset; |
---|
| 153 | + u8 vf_ctrl; |
---|
| 154 | + int err; |
---|
| 155 | + |
---|
| 156 | + err = nfp_net_sriov_check(app, vf, NFP_NET_VF_CFG_MB_CAP_TRUST, |
---|
| 157 | + "trust"); |
---|
| 158 | + if (err) |
---|
| 159 | + return err; |
---|
| 160 | + |
---|
| 161 | + /* Write trust control bit to VF entry in VF config symbol */ |
---|
| 162 | + vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ + |
---|
| 163 | + NFP_NET_VF_CFG_CTRL; |
---|
| 164 | + vf_ctrl = readb(app->pf->vfcfg_tbl2 + vf_offset); |
---|
| 165 | + vf_ctrl &= ~NFP_NET_VF_CFG_CTRL_TRUST; |
---|
| 166 | + vf_ctrl |= FIELD_PREP(NFP_NET_VF_CFG_CTRL_TRUST, enable); |
---|
| 167 | + writeb(vf_ctrl, app->pf->vfcfg_tbl2 + vf_offset); |
---|
| 168 | + |
---|
| 169 | + return nfp_net_sriov_update(app, vf, NFP_NET_VF_CFG_MB_UPD_TRUST, |
---|
| 170 | + "trust"); |
---|
| 171 | +} |
---|
| 172 | + |
---|
179 | 173 | int nfp_app_set_vf_link_state(struct net_device *netdev, int vf, |
---|
180 | 174 | int link_state) |
---|
181 | 175 | { |
---|
.. | .. |
---|
243 | 237 | ivi->qos = FIELD_GET(NFP_NET_VF_CFG_VLAN_QOS, vlan_tci); |
---|
244 | 238 | |
---|
245 | 239 | ivi->spoofchk = FIELD_GET(NFP_NET_VF_CFG_CTRL_SPOOF, flags); |
---|
| 240 | + ivi->trusted = FIELD_GET(NFP_NET_VF_CFG_CTRL_TRUST, flags); |
---|
246 | 241 | ivi->linkstate = FIELD_GET(NFP_NET_VF_CFG_CTRL_LINK_STATE, flags); |
---|
247 | 242 | |
---|
248 | 243 | return 0; |
---|