Skip to content

Commit 2a51644

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Propagate trusted VF attribute to firmware.
Newer firmware understands the concept of a trusted VF, so propagate the trusted VF attribute set by the PF admin. to the firmware. Also, check the firmware trusted setting when considering the VF MAC address change and reporting the trusted setting to the user. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c6cc32a commit 2a51644

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6683,6 +6683,10 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
66836683
VER_GET_RESP_DEV_CAPS_CFG_FLOW_HANDLE_64BIT_SUPPORTED)
66846684
bp->fw_cap |= BNXT_FW_CAP_OVS_64BIT_HANDLE;
66856685

6686+
if (dev_caps_cfg &
6687+
VER_GET_RESP_DEV_CAPS_CFG_TRUSTED_VF_SUPPORTED)
6688+
bp->fw_cap |= BNXT_FW_CAP_TRUSTED_VF;
6689+
66866690
hwrm_ver_get_exit:
66876691
mutex_unlock(&bp->hwrm_cmd_lock);
66886692
return rc;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ struct bnxt_vf_info {
945945
* stored by PF.
946946
*/
947947
u16 vlan;
948+
u16 func_qcfg_flags;
948949
u32 flags;
949950
#define BNXT_VF_QOS 0x1
950951
#define BNXT_VF_SPOOFCHK 0x2
@@ -1478,6 +1479,7 @@ struct bnxt {
14781479
#define BNXT_FW_CAP_IF_CHANGE 0x00000010
14791480
#define BNXT_FW_CAP_KONG_MB_CHNL 0x00000080
14801481
#define BNXT_FW_CAP_OVS_64BIT_HANDLE 0x00000400
1482+
#define BNXT_FW_CAP_TRUSTED_VF 0x00000800
14811483

14821484
#define BNXT_NEW_RM(bp) ((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
14831485
u32 hwrm_spec_code;

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,54 @@ int bnxt_set_vf_spoofchk(struct net_device *dev, int vf_id, bool setting)
121121
return rc;
122122
}
123123

124+
static int bnxt_hwrm_func_qcfg_flags(struct bnxt *bp, struct bnxt_vf_info *vf)
125+
{
126+
struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
127+
struct hwrm_func_qcfg_input req = {0};
128+
int rc;
129+
130+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_QCFG, -1, -1);
131+
req.fid = cpu_to_le16(vf->fw_fid);
132+
mutex_lock(&bp->hwrm_cmd_lock);
133+
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
134+
if (rc) {
135+
mutex_unlock(&bp->hwrm_cmd_lock);
136+
return -EIO;
137+
}
138+
vf->func_qcfg_flags = le16_to_cpu(resp->flags);
139+
mutex_unlock(&bp->hwrm_cmd_lock);
140+
return 0;
141+
}
142+
143+
static bool bnxt_is_trusted_vf(struct bnxt *bp, struct bnxt_vf_info *vf)
144+
{
145+
if (!(bp->fw_cap & BNXT_FW_CAP_TRUSTED_VF))
146+
return !!(vf->flags & BNXT_VF_TRUST);
147+
148+
bnxt_hwrm_func_qcfg_flags(bp, vf);
149+
return !!(vf->func_qcfg_flags & FUNC_QCFG_RESP_FLAGS_TRUSTED_VF);
150+
}
151+
152+
static int bnxt_hwrm_set_trusted_vf(struct bnxt *bp, struct bnxt_vf_info *vf)
153+
{
154+
struct hwrm_func_cfg_input req = {0};
155+
int rc;
156+
157+
if (!(bp->fw_cap & BNXT_FW_CAP_TRUSTED_VF))
158+
return 0;
159+
160+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
161+
req.fid = cpu_to_le16(vf->fw_fid);
162+
if (vf->flags & BNXT_VF_TRUST)
163+
req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_TRUSTED_VF_ENABLE);
164+
else
165+
req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_TRUSTED_VF_DISABLE);
166+
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
167+
if (rc)
168+
return -EIO;
169+
return 0;
170+
}
171+
124172
int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trusted)
125173
{
126174
struct bnxt *bp = netdev_priv(dev);
@@ -135,6 +183,7 @@ int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trusted)
135183
else
136184
vf->flags &= ~BNXT_VF_TRUST;
137185

186+
bnxt_hwrm_set_trusted_vf(bp, vf);
138187
return 0;
139188
}
140189

@@ -164,7 +213,7 @@ int bnxt_get_vf_config(struct net_device *dev, int vf_id,
164213
else
165214
ivi->qos = 0;
166215
ivi->spoofchk = !!(vf->flags & BNXT_VF_SPOOFCHK);
167-
ivi->trusted = !!(vf->flags & BNXT_VF_TRUST);
216+
ivi->trusted = bnxt_is_trusted_vf(bp, vf);
168217
if (!(vf->flags & BNXT_VF_LINK_FORCED))
169218
ivi->linkstate = IFLA_VF_LINK_STATE_AUTO;
170219
else if (vf->flags & BNXT_VF_LINK_UP)
@@ -935,9 +984,10 @@ static int bnxt_vf_configure_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
935984
* if the PF assigned MAC address is zero
936985
*/
937986
if (req->enables & cpu_to_le32(FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR)) {
987+
bool trust = bnxt_is_trusted_vf(bp, vf);
988+
938989
if (is_valid_ether_addr(req->dflt_mac_addr) &&
939-
((vf->flags & BNXT_VF_TRUST) ||
940-
!is_valid_ether_addr(vf->mac_addr) ||
990+
(trust || !is_valid_ether_addr(vf->mac_addr) ||
941991
ether_addr_equal(req->dflt_mac_addr, vf->mac_addr))) {
942992
ether_addr_copy(vf->vf_mac_addr, req->dflt_mac_addr);
943993
return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
@@ -962,7 +1012,7 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
9621012
* Otherwise, it must match the VF MAC address if firmware spec >=
9631013
* 1.2.2
9641014
*/
965-
if (vf->flags & BNXT_VF_TRUST) {
1015+
if (bnxt_is_trusted_vf(bp, vf)) {
9661016
mac_ok = true;
9671017
} else if (is_valid_ether_addr(vf->mac_addr)) {
9681018
if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))

0 commit comments

Comments
 (0)