Skip to content

Commit 9adbac5

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
fm10k: fix iov_msg_mac_vlan_pf VID checks
The VF will send a message to request multicast addresses with the default VID. In the current code, if the PF has statically assigned a VLAN to a VF, then the VF will not get the multicast addresses. Fix up all of the various VLAN messages to use identical checks (since each check was different). Also use set as a variable, so that it simplifies our check for whether VLAN matches the pf_vid. The new logic will allow set of a VLAN if it is zero, automatically converting to the default VID. Otherwise it will allow setting the PF VID, or any VLAN if PF has not statically assigned a VLAN. This is consistent behavior, and allows VF to request either 0 or the default_vid without silently failing. Note that we need the check for zero since VFs might not get the default VID message in time to actually request non-zero VLANs. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Krishneil Singh <krishneil.k.singh@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent ac98100 commit 9adbac5

File tree

1 file changed

+52
-33
lines changed

1 file changed

+52
-33
lines changed

drivers/net/ethernet/intel/fm10k/fm10k_pf.c

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,24 @@ s32 fm10k_iov_msg_msix_pf(struct fm10k_hw *hw, u32 **results,
11541154
return hw->iov.ops.assign_int_moderator(hw, vf_idx);
11551155
}
11561156

1157+
/**
1158+
* fm10k_iov_select_vid - Select correct default VID
1159+
* @hw: Pointer to hardware structure
1160+
* @vid: VID to correct
1161+
*
1162+
* Will report an error if VID is out of range. For VID = 0, it will return
1163+
* either the pf_vid or sw_vid depending on which one is set.
1164+
*/
1165+
static inline s32 fm10k_iov_select_vid(struct fm10k_vf_info *vf_info, u16 vid)
1166+
{
1167+
if (!vid)
1168+
return vf_info->pf_vid ? vf_info->pf_vid : vf_info->sw_vid;
1169+
else if (vf_info->pf_vid && vid != vf_info->pf_vid)
1170+
return FM10K_ERR_PARAM;
1171+
else
1172+
return vid;
1173+
}
1174+
11571175
/**
11581176
* fm10k_iov_msg_mac_vlan_pf - Message handler for MAC/VLAN request from VF
11591177
* @hw: Pointer to hardware structure
@@ -1168,9 +1186,10 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
11681186
struct fm10k_mbx_info *mbx)
11691187
{
11701188
struct fm10k_vf_info *vf_info = (struct fm10k_vf_info *)mbx;
1171-
int err = 0;
11721189
u8 mac[ETH_ALEN];
11731190
u32 *result;
1191+
int err = 0;
1192+
bool set;
11741193
u16 vlan;
11751194
u32 vid;
11761195

@@ -1186,19 +1205,21 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
11861205
if (err)
11871206
return err;
11881207

1189-
/* if VLAN ID is 0, set the default VLAN ID instead of 0 */
1190-
if (!vid || (vid == FM10K_VLAN_CLEAR)) {
1191-
if (vf_info->pf_vid)
1192-
vid |= vf_info->pf_vid;
1193-
else
1194-
vid |= vf_info->sw_vid;
1195-
} else if (vid != vf_info->pf_vid) {
1208+
/* verify upper 16 bits are zero */
1209+
if (vid >> 16)
11961210
return FM10K_ERR_PARAM;
1197-
}
1211+
1212+
set = !(vid & FM10K_VLAN_CLEAR);
1213+
vid &= ~FM10K_VLAN_CLEAR;
1214+
1215+
err = fm10k_iov_select_vid(vf_info, vid);
1216+
if (err < 0)
1217+
return err;
1218+
else
1219+
vid = err;
11981220

11991221
/* update VSI info for VF in regards to VLAN table */
1200-
err = hw->mac.ops.update_vlan(hw, vid, vf_info->vsi,
1201-
!(vid & FM10K_VLAN_CLEAR));
1222+
err = hw->mac.ops.update_vlan(hw, vid, vf_info->vsi, set);
12021223
}
12031224

12041225
if (!err && !!results[FM10K_MAC_VLAN_MSG_MAC]) {
@@ -1214,19 +1235,18 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
12141235
memcmp(mac, vf_info->mac, ETH_ALEN))
12151236
return FM10K_ERR_PARAM;
12161237

1217-
/* if VLAN ID is 0, set the default VLAN ID instead of 0 */
1218-
if (!vlan || (vlan == FM10K_VLAN_CLEAR)) {
1219-
if (vf_info->pf_vid)
1220-
vlan |= vf_info->pf_vid;
1221-
else
1222-
vlan |= vf_info->sw_vid;
1223-
} else if (vf_info->pf_vid) {
1224-
return FM10K_ERR_PARAM;
1225-
}
1238+
set = !(vlan & FM10K_VLAN_CLEAR);
1239+
vlan &= ~FM10K_VLAN_CLEAR;
1240+
1241+
err = fm10k_iov_select_vid(vf_info, vlan);
1242+
if (err < 0)
1243+
return err;
1244+
else
1245+
vlan = err;
12261246

12271247
/* notify switch of request for new unicast address */
1228-
err = hw->mac.ops.update_uc_addr(hw, vf_info->glort, mac, vlan,
1229-
!(vlan & FM10K_VLAN_CLEAR), 0);
1248+
err = hw->mac.ops.update_uc_addr(hw, vf_info->glort,
1249+
mac, vlan, set, 0);
12301250
}
12311251

12321252
if (!err && !!results[FM10K_MAC_VLAN_MSG_MULTICAST]) {
@@ -1241,19 +1261,18 @@ s32 fm10k_iov_msg_mac_vlan_pf(struct fm10k_hw *hw, u32 **results,
12411261
if (!(vf_info->vf_flags & FM10K_VF_FLAG_MULTI_ENABLED))
12421262
return FM10K_ERR_PARAM;
12431263

1244-
/* if VLAN ID is 0, set the default VLAN ID instead of 0 */
1245-
if (!vlan || (vlan == FM10K_VLAN_CLEAR)) {
1246-
if (vf_info->pf_vid)
1247-
vlan |= vf_info->pf_vid;
1248-
else
1249-
vlan |= vf_info->sw_vid;
1250-
} else if (vf_info->pf_vid) {
1251-
return FM10K_ERR_PARAM;
1252-
}
1264+
set = !(vlan & FM10K_VLAN_CLEAR);
1265+
vlan &= ~FM10K_VLAN_CLEAR;
1266+
1267+
err = fm10k_iov_select_vid(vf_info, vlan);
1268+
if (err < 0)
1269+
return err;
1270+
else
1271+
vlan = err;
12531272

12541273
/* notify switch of request for new multicast address */
1255-
err = hw->mac.ops.update_mc_addr(hw, vf_info->glort, mac, vlan,
1256-
!(vlan & FM10K_VLAN_CLEAR));
1274+
err = hw->mac.ops.update_mc_addr(hw, vf_info->glort,
1275+
mac, vlan, set);
12571276
}
12581277

12591278
return err;

0 commit comments

Comments
 (0)