| .. | .. |
|---|
| 130 | 130 | /***********************misc routines*****************************/ |
|---|
| 131 | 131 | |
|---|
| 132 | 132 | /** |
|---|
| 133 | | - * i40e_vc_disable_vf |
|---|
| 133 | + * i40e_vc_reset_vf |
|---|
| 134 | 134 | * @vf: pointer to the VF info |
|---|
| 135 | | - * |
|---|
| 136 | | - * Disable the VF through a SW reset. |
|---|
| 135 | + * @notify_vf: notify vf about reset or not |
|---|
| 136 | + * Reset VF handler. |
|---|
| 137 | 137 | **/ |
|---|
| 138 | | -static inline void i40e_vc_disable_vf(struct i40e_vf *vf) |
|---|
| 138 | +static void i40e_vc_reset_vf(struct i40e_vf *vf, bool notify_vf) |
|---|
| 139 | 139 | { |
|---|
| 140 | 140 | struct i40e_pf *pf = vf->pf; |
|---|
| 141 | 141 | int i; |
|---|
| 142 | 142 | |
|---|
| 143 | | - i40e_vc_notify_vf_reset(vf); |
|---|
| 143 | + if (notify_vf) |
|---|
| 144 | + i40e_vc_notify_vf_reset(vf); |
|---|
| 144 | 145 | |
|---|
| 145 | 146 | /* We want to ensure that an actual reset occurs initiated after this |
|---|
| 146 | 147 | * function was called. However, we do not want to wait forever, so |
|---|
| .. | .. |
|---|
| 158 | 159 | usleep_range(10000, 20000); |
|---|
| 159 | 160 | } |
|---|
| 160 | 161 | |
|---|
| 161 | | - dev_warn(&vf->pf->pdev->dev, |
|---|
| 162 | | - "Failed to initiate reset for VF %d after 200 milliseconds\n", |
|---|
| 163 | | - vf->vf_id); |
|---|
| 162 | + if (notify_vf) |
|---|
| 163 | + dev_warn(&vf->pf->pdev->dev, |
|---|
| 164 | + "Failed to initiate reset for VF %d after 200 milliseconds\n", |
|---|
| 165 | + vf->vf_id); |
|---|
| 166 | + else |
|---|
| 167 | + dev_dbg(&vf->pf->pdev->dev, |
|---|
| 168 | + "Failed to initiate reset for VF %d after 200 milliseconds\n", |
|---|
| 169 | + vf->vf_id); |
|---|
| 164 | 170 | } |
|---|
| 165 | 171 | |
|---|
| 166 | 172 | /** |
|---|
| .. | .. |
|---|
| 446 | 452 | struct virtchnl_iwarp_qv_info *qv_info; |
|---|
| 447 | 453 | u32 v_idx, i, reg_idx, reg; |
|---|
| 448 | 454 | u32 next_q_idx, next_q_type; |
|---|
| 449 | | - u32 msix_vf, size; |
|---|
| 455 | + u32 msix_vf; |
|---|
| 450 | 456 | int ret = 0; |
|---|
| 451 | 457 | |
|---|
| 452 | 458 | msix_vf = pf->hw.func_caps.num_msix_vectors_vf; |
|---|
| .. | .. |
|---|
| 460 | 466 | goto err_out; |
|---|
| 461 | 467 | } |
|---|
| 462 | 468 | |
|---|
| 463 | | - size = sizeof(struct virtchnl_iwarp_qvlist_info) + |
|---|
| 464 | | - (sizeof(struct virtchnl_iwarp_qv_info) * |
|---|
| 465 | | - (qvlist_info->num_vectors - 1)); |
|---|
| 466 | 469 | kfree(vf->qvlist_info); |
|---|
| 467 | | - vf->qvlist_info = kzalloc(size, GFP_KERNEL); |
|---|
| 470 | + vf->qvlist_info = kzalloc(struct_size(vf->qvlist_info, qv_info, |
|---|
| 471 | + qvlist_info->num_vectors - 1), |
|---|
| 472 | + GFP_KERNEL); |
|---|
| 468 | 473 | if (!vf->qvlist_info) { |
|---|
| 469 | 474 | ret = -ENOMEM; |
|---|
| 470 | 475 | goto err_out; |
|---|
| .. | .. |
|---|
| 476 | 481 | qv_info = &qvlist_info->qv_info[i]; |
|---|
| 477 | 482 | if (!qv_info) |
|---|
| 478 | 483 | continue; |
|---|
| 479 | | - v_idx = qv_info->v_idx; |
|---|
| 480 | 484 | |
|---|
| 481 | 485 | /* Validate vector id belongs to this vf */ |
|---|
| 482 | | - if (!i40e_vc_isvalid_vector_id(vf, v_idx)) { |
|---|
| 486 | + if (!i40e_vc_isvalid_vector_id(vf, qv_info->v_idx)) { |
|---|
| 483 | 487 | ret = -EINVAL; |
|---|
| 484 | 488 | goto err_free; |
|---|
| 485 | 489 | } |
|---|
| 490 | + |
|---|
| 491 | + v_idx = qv_info->v_idx; |
|---|
| 486 | 492 | |
|---|
| 487 | 493 | vf->qvlist_info->qv_info[i] = *qv_info; |
|---|
| 488 | 494 | |
|---|
| .. | .. |
|---|
| 958 | 964 | i40e_vsi_release(pf->vsi[vf->lan_vsi_idx]); |
|---|
| 959 | 965 | vf->lan_vsi_idx = 0; |
|---|
| 960 | 966 | vf->lan_vsi_id = 0; |
|---|
| 961 | | - vf->num_mac = 0; |
|---|
| 962 | 967 | } |
|---|
| 963 | 968 | |
|---|
| 964 | 969 | /* do the accounting and remove additional ADq VSI's */ |
|---|
| .. | .. |
|---|
| 1111 | 1116 | } |
|---|
| 1112 | 1117 | |
|---|
| 1113 | 1118 | /** |
|---|
| 1119 | + * __i40e_getnum_vf_vsi_vlan_filters |
|---|
| 1120 | + * @vsi: pointer to the vsi |
|---|
| 1121 | + * |
|---|
| 1122 | + * called to get the number of VLANs offloaded on this VF |
|---|
| 1123 | + **/ |
|---|
| 1124 | +static int __i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi) |
|---|
| 1125 | +{ |
|---|
| 1126 | + struct i40e_mac_filter *f; |
|---|
| 1127 | + u16 num_vlans = 0, bkt; |
|---|
| 1128 | + |
|---|
| 1129 | + hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) { |
|---|
| 1130 | + if (f->vlan >= 0 && f->vlan <= I40E_MAX_VLANID) |
|---|
| 1131 | + num_vlans++; |
|---|
| 1132 | + } |
|---|
| 1133 | + |
|---|
| 1134 | + return num_vlans; |
|---|
| 1135 | +} |
|---|
| 1136 | + |
|---|
| 1137 | +/** |
|---|
| 1138 | + * i40e_getnum_vf_vsi_vlan_filters |
|---|
| 1139 | + * @vsi: pointer to the vsi |
|---|
| 1140 | + * |
|---|
| 1141 | + * wrapper for __i40e_getnum_vf_vsi_vlan_filters() with spinlock held |
|---|
| 1142 | + **/ |
|---|
| 1143 | +static int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi) |
|---|
| 1144 | +{ |
|---|
| 1145 | + int num_vlans; |
|---|
| 1146 | + |
|---|
| 1147 | + spin_lock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 1148 | + num_vlans = __i40e_getnum_vf_vsi_vlan_filters(vsi); |
|---|
| 1149 | + spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 1150 | + |
|---|
| 1151 | + return num_vlans; |
|---|
| 1152 | +} |
|---|
| 1153 | + |
|---|
| 1154 | +/** |
|---|
| 1155 | + * i40e_get_vlan_list_sync |
|---|
| 1156 | + * @vsi: pointer to the VSI |
|---|
| 1157 | + * @num_vlans: number of VLANs in mac_filter_hash, returned to caller |
|---|
| 1158 | + * @vlan_list: list of VLANs present in mac_filter_hash, returned to caller. |
|---|
| 1159 | + * This array is allocated here, but has to be freed in caller. |
|---|
| 1160 | + * |
|---|
| 1161 | + * Called to get number of VLANs and VLAN list present in mac_filter_hash. |
|---|
| 1162 | + **/ |
|---|
| 1163 | +static void i40e_get_vlan_list_sync(struct i40e_vsi *vsi, u16 *num_vlans, |
|---|
| 1164 | + s16 **vlan_list) |
|---|
| 1165 | +{ |
|---|
| 1166 | + struct i40e_mac_filter *f; |
|---|
| 1167 | + int i = 0; |
|---|
| 1168 | + int bkt; |
|---|
| 1169 | + |
|---|
| 1170 | + spin_lock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 1171 | + *num_vlans = __i40e_getnum_vf_vsi_vlan_filters(vsi); |
|---|
| 1172 | + *vlan_list = kcalloc(*num_vlans, sizeof(**vlan_list), GFP_ATOMIC); |
|---|
| 1173 | + if (!(*vlan_list)) |
|---|
| 1174 | + goto err; |
|---|
| 1175 | + |
|---|
| 1176 | + hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) { |
|---|
| 1177 | + if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID) |
|---|
| 1178 | + continue; |
|---|
| 1179 | + (*vlan_list)[i++] = f->vlan; |
|---|
| 1180 | + } |
|---|
| 1181 | +err: |
|---|
| 1182 | + spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 1183 | +} |
|---|
| 1184 | + |
|---|
| 1185 | +/** |
|---|
| 1186 | + * i40e_set_vsi_promisc |
|---|
| 1187 | + * @vf: pointer to the VF struct |
|---|
| 1188 | + * @seid: VSI number |
|---|
| 1189 | + * @multi_enable: set MAC L2 layer multicast promiscuous enable/disable |
|---|
| 1190 | + * for a given VLAN |
|---|
| 1191 | + * @unicast_enable: set MAC L2 layer unicast promiscuous enable/disable |
|---|
| 1192 | + * for a given VLAN |
|---|
| 1193 | + * @vl: List of VLANs - apply filter for given VLANs |
|---|
| 1194 | + * @num_vlans: Number of elements in @vl |
|---|
| 1195 | + **/ |
|---|
| 1196 | +static i40e_status |
|---|
| 1197 | +i40e_set_vsi_promisc(struct i40e_vf *vf, u16 seid, bool multi_enable, |
|---|
| 1198 | + bool unicast_enable, s16 *vl, u16 num_vlans) |
|---|
| 1199 | +{ |
|---|
| 1200 | + i40e_status aq_ret, aq_tmp = 0; |
|---|
| 1201 | + struct i40e_pf *pf = vf->pf; |
|---|
| 1202 | + struct i40e_hw *hw = &pf->hw; |
|---|
| 1203 | + int i; |
|---|
| 1204 | + |
|---|
| 1205 | + /* No VLAN to set promisc on, set on VSI */ |
|---|
| 1206 | + if (!num_vlans || !vl) { |
|---|
| 1207 | + aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, seid, |
|---|
| 1208 | + multi_enable, |
|---|
| 1209 | + NULL); |
|---|
| 1210 | + if (aq_ret) { |
|---|
| 1211 | + int aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1212 | + |
|---|
| 1213 | + dev_err(&pf->pdev->dev, |
|---|
| 1214 | + "VF %d failed to set multicast promiscuous mode err %s aq_err %s\n", |
|---|
| 1215 | + vf->vf_id, |
|---|
| 1216 | + i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1217 | + i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1218 | + |
|---|
| 1219 | + return aq_ret; |
|---|
| 1220 | + } |
|---|
| 1221 | + |
|---|
| 1222 | + aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, seid, |
|---|
| 1223 | + unicast_enable, |
|---|
| 1224 | + NULL, true); |
|---|
| 1225 | + |
|---|
| 1226 | + if (aq_ret) { |
|---|
| 1227 | + int aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1228 | + |
|---|
| 1229 | + dev_err(&pf->pdev->dev, |
|---|
| 1230 | + "VF %d failed to set unicast promiscuous mode err %s aq_err %s\n", |
|---|
| 1231 | + vf->vf_id, |
|---|
| 1232 | + i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1233 | + i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1234 | + } |
|---|
| 1235 | + |
|---|
| 1236 | + return aq_ret; |
|---|
| 1237 | + } |
|---|
| 1238 | + |
|---|
| 1239 | + for (i = 0; i < num_vlans; i++) { |
|---|
| 1240 | + aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, seid, |
|---|
| 1241 | + multi_enable, |
|---|
| 1242 | + vl[i], NULL); |
|---|
| 1243 | + if (aq_ret) { |
|---|
| 1244 | + int aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1245 | + |
|---|
| 1246 | + dev_err(&pf->pdev->dev, |
|---|
| 1247 | + "VF %d failed to set multicast promiscuous mode err %s aq_err %s\n", |
|---|
| 1248 | + vf->vf_id, |
|---|
| 1249 | + i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1250 | + i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1251 | + |
|---|
| 1252 | + if (!aq_tmp) |
|---|
| 1253 | + aq_tmp = aq_ret; |
|---|
| 1254 | + } |
|---|
| 1255 | + |
|---|
| 1256 | + aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, seid, |
|---|
| 1257 | + unicast_enable, |
|---|
| 1258 | + vl[i], NULL); |
|---|
| 1259 | + if (aq_ret) { |
|---|
| 1260 | + int aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1261 | + |
|---|
| 1262 | + dev_err(&pf->pdev->dev, |
|---|
| 1263 | + "VF %d failed to set unicast promiscuous mode err %s aq_err %s\n", |
|---|
| 1264 | + vf->vf_id, |
|---|
| 1265 | + i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1266 | + i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1267 | + |
|---|
| 1268 | + if (!aq_tmp) |
|---|
| 1269 | + aq_tmp = aq_ret; |
|---|
| 1270 | + } |
|---|
| 1271 | + } |
|---|
| 1272 | + |
|---|
| 1273 | + if (aq_tmp) |
|---|
| 1274 | + aq_ret = aq_tmp; |
|---|
| 1275 | + |
|---|
| 1276 | + return aq_ret; |
|---|
| 1277 | +} |
|---|
| 1278 | + |
|---|
| 1279 | +/** |
|---|
| 1280 | + * i40e_config_vf_promiscuous_mode |
|---|
| 1281 | + * @vf: pointer to the VF info |
|---|
| 1282 | + * @vsi_id: VSI id |
|---|
| 1283 | + * @allmulti: set MAC L2 layer multicast promiscuous enable/disable |
|---|
| 1284 | + * @alluni: set MAC L2 layer unicast promiscuous enable/disable |
|---|
| 1285 | + * |
|---|
| 1286 | + * Called from the VF to configure the promiscuous mode of |
|---|
| 1287 | + * VF vsis and from the VF reset path to reset promiscuous mode. |
|---|
| 1288 | + **/ |
|---|
| 1289 | +static i40e_status i40e_config_vf_promiscuous_mode(struct i40e_vf *vf, |
|---|
| 1290 | + u16 vsi_id, |
|---|
| 1291 | + bool allmulti, |
|---|
| 1292 | + bool alluni) |
|---|
| 1293 | +{ |
|---|
| 1294 | + i40e_status aq_ret = I40E_SUCCESS; |
|---|
| 1295 | + struct i40e_pf *pf = vf->pf; |
|---|
| 1296 | + struct i40e_vsi *vsi; |
|---|
| 1297 | + u16 num_vlans; |
|---|
| 1298 | + s16 *vl; |
|---|
| 1299 | + |
|---|
| 1300 | + vsi = i40e_find_vsi_from_id(pf, vsi_id); |
|---|
| 1301 | + if (!i40e_vc_isvalid_vsi_id(vf, vsi_id) || !vsi) |
|---|
| 1302 | + return I40E_ERR_PARAM; |
|---|
| 1303 | + |
|---|
| 1304 | + if (vf->port_vlan_id) { |
|---|
| 1305 | + aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, |
|---|
| 1306 | + alluni, &vf->port_vlan_id, 1); |
|---|
| 1307 | + return aq_ret; |
|---|
| 1308 | + } else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) { |
|---|
| 1309 | + i40e_get_vlan_list_sync(vsi, &num_vlans, &vl); |
|---|
| 1310 | + |
|---|
| 1311 | + if (!vl) |
|---|
| 1312 | + return I40E_ERR_NO_MEMORY; |
|---|
| 1313 | + |
|---|
| 1314 | + aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, alluni, |
|---|
| 1315 | + vl, num_vlans); |
|---|
| 1316 | + kfree(vl); |
|---|
| 1317 | + return aq_ret; |
|---|
| 1318 | + } |
|---|
| 1319 | + |
|---|
| 1320 | + /* no VLANs to set on, set on VSI */ |
|---|
| 1321 | + aq_ret = i40e_set_vsi_promisc(vf, vsi->seid, allmulti, alluni, |
|---|
| 1322 | + NULL, 0); |
|---|
| 1323 | + return aq_ret; |
|---|
| 1324 | +} |
|---|
| 1325 | + |
|---|
| 1326 | +/** |
|---|
| 1327 | + * i40e_sync_vfr_reset |
|---|
| 1328 | + * @hw: pointer to hw struct |
|---|
| 1329 | + * @vf_id: VF identifier |
|---|
| 1330 | + * |
|---|
| 1331 | + * Before trigger hardware reset, we need to know if no other process has |
|---|
| 1332 | + * reserved the hardware for any reset operations. This check is done by |
|---|
| 1333 | + * examining the status of the RSTAT1 register used to signal the reset. |
|---|
| 1334 | + **/ |
|---|
| 1335 | +static int i40e_sync_vfr_reset(struct i40e_hw *hw, int vf_id) |
|---|
| 1336 | +{ |
|---|
| 1337 | + u32 reg; |
|---|
| 1338 | + int i; |
|---|
| 1339 | + |
|---|
| 1340 | + for (i = 0; i < I40E_VFR_WAIT_COUNT; i++) { |
|---|
| 1341 | + reg = rd32(hw, I40E_VFINT_ICR0_ENA(vf_id)) & |
|---|
| 1342 | + I40E_VFINT_ICR0_ADMINQ_MASK; |
|---|
| 1343 | + if (reg) |
|---|
| 1344 | + return 0; |
|---|
| 1345 | + |
|---|
| 1346 | + usleep_range(100, 200); |
|---|
| 1347 | + } |
|---|
| 1348 | + |
|---|
| 1349 | + return -EAGAIN; |
|---|
| 1350 | +} |
|---|
| 1351 | + |
|---|
| 1352 | +/** |
|---|
| 1114 | 1353 | * i40e_trigger_vf_reset |
|---|
| 1115 | 1354 | * @vf: pointer to the VF structure |
|---|
| 1116 | 1355 | * @flr: VFLR was issued or not |
|---|
| .. | .. |
|---|
| 1124 | 1363 | struct i40e_pf *pf = vf->pf; |
|---|
| 1125 | 1364 | struct i40e_hw *hw = &pf->hw; |
|---|
| 1126 | 1365 | u32 reg, reg_idx, bit_idx; |
|---|
| 1366 | + bool vf_active; |
|---|
| 1367 | + u32 radq; |
|---|
| 1127 | 1368 | |
|---|
| 1128 | 1369 | /* warn the VF */ |
|---|
| 1129 | | - clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); |
|---|
| 1370 | + vf_active = test_and_clear_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states); |
|---|
| 1130 | 1371 | |
|---|
| 1131 | 1372 | /* Disable VF's configuration API during reset. The flag is re-enabled |
|---|
| 1132 | 1373 | * in i40e_alloc_vf_res(), when it's safe again to access VF's VSI. |
|---|
| .. | .. |
|---|
| 1140 | 1381 | * just need to clean up, so don't hit the VFRTRIG register. |
|---|
| 1141 | 1382 | */ |
|---|
| 1142 | 1383 | if (!flr) { |
|---|
| 1143 | | - /* reset VF using VPGEN_VFRTRIG reg */ |
|---|
| 1384 | + /* Sync VFR reset before trigger next one */ |
|---|
| 1385 | + radq = rd32(hw, I40E_VFINT_ICR0_ENA(vf->vf_id)) & |
|---|
| 1386 | + I40E_VFINT_ICR0_ADMINQ_MASK; |
|---|
| 1387 | + if (vf_active && !radq) |
|---|
| 1388 | + /* waiting for finish reset by virtual driver */ |
|---|
| 1389 | + if (i40e_sync_vfr_reset(hw, vf->vf_id)) |
|---|
| 1390 | + dev_info(&pf->pdev->dev, |
|---|
| 1391 | + "Reset VF %d never finished\n", |
|---|
| 1392 | + vf->vf_id); |
|---|
| 1393 | + |
|---|
| 1394 | + /* Reset VF using VPGEN_VFRTRIG reg. It is also setting |
|---|
| 1395 | + * in progress state in rstat1 register. |
|---|
| 1396 | + */ |
|---|
| 1144 | 1397 | reg = rd32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id)); |
|---|
| 1145 | 1398 | reg |= I40E_VPGEN_VFRTRIG_VFSWR_MASK; |
|---|
| 1146 | 1399 | wr32(hw, I40E_VPGEN_VFRTRIG(vf->vf_id), reg); |
|---|
| .. | .. |
|---|
| 1170 | 1423 | struct i40e_pf *pf = vf->pf; |
|---|
| 1171 | 1424 | struct i40e_hw *hw = &pf->hw; |
|---|
| 1172 | 1425 | u32 reg; |
|---|
| 1426 | + |
|---|
| 1427 | + /* disable promisc modes in case they were enabled */ |
|---|
| 1428 | + i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, false, false); |
|---|
| 1173 | 1429 | |
|---|
| 1174 | 1430 | /* free VF resources to begin resetting the VSI state */ |
|---|
| 1175 | 1431 | i40e_free_vf_res(vf); |
|---|
| .. | .. |
|---|
| 1227 | 1483 | if (test_bit(__I40E_VF_RESETS_DISABLED, pf->state)) |
|---|
| 1228 | 1484 | return true; |
|---|
| 1229 | 1485 | |
|---|
| 1230 | | - /* If the VFs have been disabled, this means something else is |
|---|
| 1231 | | - * resetting the VF, so we shouldn't continue. |
|---|
| 1232 | | - */ |
|---|
| 1233 | | - if (test_and_set_bit(__I40E_VF_DISABLE, pf->state)) |
|---|
| 1486 | + /* Bail out if VFs are disabled. */ |
|---|
| 1487 | + if (test_bit(__I40E_VF_DISABLE, pf->state)) |
|---|
| 1488 | + return true; |
|---|
| 1489 | + |
|---|
| 1490 | + /* If VF is being reset already we don't need to continue. */ |
|---|
| 1491 | + if (test_and_set_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) |
|---|
| 1234 | 1492 | return true; |
|---|
| 1235 | 1493 | |
|---|
| 1236 | 1494 | i40e_trigger_vf_reset(vf, flr); |
|---|
| .. | .. |
|---|
| 1267 | 1525 | i40e_cleanup_reset_vf(vf); |
|---|
| 1268 | 1526 | |
|---|
| 1269 | 1527 | i40e_flush(hw); |
|---|
| 1270 | | - clear_bit(__I40E_VF_DISABLE, pf->state); |
|---|
| 1528 | + usleep_range(20000, 40000); |
|---|
| 1529 | + clear_bit(I40E_VF_STATE_RESETTING, &vf->vf_states); |
|---|
| 1271 | 1530 | |
|---|
| 1272 | 1531 | return true; |
|---|
| 1273 | 1532 | } |
|---|
| .. | .. |
|---|
| 1300 | 1559 | return false; |
|---|
| 1301 | 1560 | |
|---|
| 1302 | 1561 | /* Begin reset on all VFs at once */ |
|---|
| 1303 | | - for (v = 0; v < pf->num_alloc_vfs; v++) |
|---|
| 1304 | | - i40e_trigger_vf_reset(&pf->vf[v], flr); |
|---|
| 1562 | + for (v = 0; v < pf->num_alloc_vfs; v++) { |
|---|
| 1563 | + vf = &pf->vf[v]; |
|---|
| 1564 | + /* If VF is being reset no need to trigger reset again */ |
|---|
| 1565 | + if (!test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) |
|---|
| 1566 | + i40e_trigger_vf_reset(&pf->vf[v], flr); |
|---|
| 1567 | + } |
|---|
| 1305 | 1568 | |
|---|
| 1306 | 1569 | /* HW requires some time to make sure it can flush the FIFO for a VF |
|---|
| 1307 | 1570 | * when it resets it. Poll the VPGEN_VFRSTAT register for each VF in |
|---|
| .. | .. |
|---|
| 1317 | 1580 | */ |
|---|
| 1318 | 1581 | while (v < pf->num_alloc_vfs) { |
|---|
| 1319 | 1582 | vf = &pf->vf[v]; |
|---|
| 1320 | | - reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id)); |
|---|
| 1321 | | - if (!(reg & I40E_VPGEN_VFRSTAT_VFRD_MASK)) |
|---|
| 1322 | | - break; |
|---|
| 1583 | + if (!test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) { |
|---|
| 1584 | + reg = rd32(hw, I40E_VPGEN_VFRSTAT(vf->vf_id)); |
|---|
| 1585 | + if (!(reg & I40E_VPGEN_VFRSTAT_VFRD_MASK)) |
|---|
| 1586 | + break; |
|---|
| 1587 | + } |
|---|
| 1323 | 1588 | |
|---|
| 1324 | 1589 | /* If the current VF has finished resetting, move on |
|---|
| 1325 | 1590 | * to the next VF in sequence. |
|---|
| .. | .. |
|---|
| 1347 | 1612 | if (pf->vf[v].lan_vsi_idx == 0) |
|---|
| 1348 | 1613 | continue; |
|---|
| 1349 | 1614 | |
|---|
| 1615 | + /* If VF is reset in another thread just continue */ |
|---|
| 1616 | + if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) |
|---|
| 1617 | + continue; |
|---|
| 1618 | + |
|---|
| 1350 | 1619 | i40e_vsi_stop_rings_no_wait(pf->vsi[pf->vf[v].lan_vsi_idx]); |
|---|
| 1351 | 1620 | } |
|---|
| 1352 | 1621 | |
|---|
| .. | .. |
|---|
| 1358 | 1627 | if (pf->vf[v].lan_vsi_idx == 0) |
|---|
| 1359 | 1628 | continue; |
|---|
| 1360 | 1629 | |
|---|
| 1630 | + /* If VF is reset in another thread just continue */ |
|---|
| 1631 | + if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) |
|---|
| 1632 | + continue; |
|---|
| 1633 | + |
|---|
| 1361 | 1634 | i40e_vsi_wait_queues_disabled(pf->vsi[pf->vf[v].lan_vsi_idx]); |
|---|
| 1362 | 1635 | } |
|---|
| 1363 | 1636 | |
|---|
| .. | .. |
|---|
| 1367 | 1640 | mdelay(50); |
|---|
| 1368 | 1641 | |
|---|
| 1369 | 1642 | /* Finish the reset on each VF */ |
|---|
| 1370 | | - for (v = 0; v < pf->num_alloc_vfs; v++) |
|---|
| 1643 | + for (v = 0; v < pf->num_alloc_vfs; v++) { |
|---|
| 1644 | + /* If VF is reset in another thread just continue */ |
|---|
| 1645 | + if (test_bit(I40E_VF_STATE_RESETTING, &vf->vf_states)) |
|---|
| 1646 | + continue; |
|---|
| 1647 | + |
|---|
| 1371 | 1648 | i40e_cleanup_reset_vf(&pf->vf[v]); |
|---|
| 1649 | + } |
|---|
| 1372 | 1650 | |
|---|
| 1373 | 1651 | i40e_flush(hw); |
|---|
| 1652 | + usleep_range(20000, 40000); |
|---|
| 1374 | 1653 | clear_bit(__I40E_VF_DISABLE, pf->state); |
|---|
| 1375 | 1654 | |
|---|
| 1376 | 1655 | return true; |
|---|
| .. | .. |
|---|
| 1575 | 1854 | int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) |
|---|
| 1576 | 1855 | { |
|---|
| 1577 | 1856 | struct i40e_pf *pf = pci_get_drvdata(pdev); |
|---|
| 1857 | + int ret = 0; |
|---|
| 1858 | + |
|---|
| 1859 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 1860 | + dev_warn(&pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 1861 | + return -EAGAIN; |
|---|
| 1862 | + } |
|---|
| 1578 | 1863 | |
|---|
| 1579 | 1864 | if (num_vfs) { |
|---|
| 1580 | 1865 | if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { |
|---|
| 1581 | 1866 | pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; |
|---|
| 1582 | 1867 | i40e_do_reset_safe(pf, I40E_PF_RESET_AND_REBUILD_FLAG); |
|---|
| 1583 | 1868 | } |
|---|
| 1584 | | - return i40e_pci_sriov_enable(pdev, num_vfs); |
|---|
| 1869 | + ret = i40e_pci_sriov_enable(pdev, num_vfs); |
|---|
| 1870 | + goto sriov_configure_out; |
|---|
| 1585 | 1871 | } |
|---|
| 1586 | 1872 | |
|---|
| 1587 | 1873 | if (!pci_vfs_assigned(pf->pdev)) { |
|---|
| .. | .. |
|---|
| 1590 | 1876 | i40e_do_reset_safe(pf, I40E_PF_RESET_AND_REBUILD_FLAG); |
|---|
| 1591 | 1877 | } else { |
|---|
| 1592 | 1878 | dev_warn(&pdev->dev, "Unable to free VFs because some are assigned to VMs.\n"); |
|---|
| 1593 | | - return -EINVAL; |
|---|
| 1879 | + ret = -EINVAL; |
|---|
| 1880 | + goto sriov_configure_out; |
|---|
| 1594 | 1881 | } |
|---|
| 1595 | | - return 0; |
|---|
| 1882 | +sriov_configure_out: |
|---|
| 1883 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 1884 | + return ret; |
|---|
| 1596 | 1885 | } |
|---|
| 1597 | 1886 | |
|---|
| 1598 | 1887 | /***********************virtual channel routines******************/ |
|---|
| .. | .. |
|---|
| 1623 | 1912 | hw = &pf->hw; |
|---|
| 1624 | 1913 | abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id; |
|---|
| 1625 | 1914 | |
|---|
| 1626 | | - /* single place to detect unsuccessful return values */ |
|---|
| 1627 | | - if (v_retval) { |
|---|
| 1628 | | - vf->num_invalid_msgs++; |
|---|
| 1629 | | - dev_info(&pf->pdev->dev, "VF %d failed opcode %d, retval: %d\n", |
|---|
| 1630 | | - vf->vf_id, v_opcode, v_retval); |
|---|
| 1631 | | - if (vf->num_invalid_msgs > |
|---|
| 1632 | | - I40E_DEFAULT_NUM_INVALID_MSGS_ALLOWED) { |
|---|
| 1633 | | - dev_err(&pf->pdev->dev, |
|---|
| 1634 | | - "Number of invalid messages exceeded for VF %d\n", |
|---|
| 1635 | | - vf->vf_id); |
|---|
| 1636 | | - dev_err(&pf->pdev->dev, "Use PF Control I/F to enable the VF\n"); |
|---|
| 1637 | | - set_bit(I40E_VF_STATE_DISABLED, &vf->vf_states); |
|---|
| 1638 | | - } |
|---|
| 1639 | | - } else { |
|---|
| 1640 | | - vf->num_valid_msgs++; |
|---|
| 1641 | | - /* reset the invalid counter, if a valid message is received. */ |
|---|
| 1642 | | - vf->num_invalid_msgs = 0; |
|---|
| 1643 | | - } |
|---|
| 1644 | | - |
|---|
| 1645 | 1915 | aq_ret = i40e_aq_send_msg_to_vf(hw, abs_vf_id, v_opcode, v_retval, |
|---|
| 1646 | 1916 | msg, msglen, NULL); |
|---|
| 1647 | 1917 | if (aq_ret) { |
|---|
| .. | .. |
|---|
| 1667 | 1937 | i40e_status retval) |
|---|
| 1668 | 1938 | { |
|---|
| 1669 | 1939 | return i40e_vc_send_msg_to_vf(vf, opcode, retval, NULL, 0); |
|---|
| 1940 | +} |
|---|
| 1941 | + |
|---|
| 1942 | +/** |
|---|
| 1943 | + * i40e_sync_vf_state |
|---|
| 1944 | + * @vf: pointer to the VF info |
|---|
| 1945 | + * @state: VF state |
|---|
| 1946 | + * |
|---|
| 1947 | + * Called from a VF message to synchronize the service with a potential |
|---|
| 1948 | + * VF reset state |
|---|
| 1949 | + **/ |
|---|
| 1950 | +static bool i40e_sync_vf_state(struct i40e_vf *vf, enum i40e_vf_states state) |
|---|
| 1951 | +{ |
|---|
| 1952 | + int i; |
|---|
| 1953 | + |
|---|
| 1954 | + /* When handling some messages, it needs VF state to be set. |
|---|
| 1955 | + * It is possible that this flag is cleared during VF reset, |
|---|
| 1956 | + * so there is a need to wait until the end of the reset to |
|---|
| 1957 | + * handle the request message correctly. |
|---|
| 1958 | + */ |
|---|
| 1959 | + for (i = 0; i < I40E_VF_STATE_WAIT_COUNT; i++) { |
|---|
| 1960 | + if (test_bit(state, &vf->vf_states)) |
|---|
| 1961 | + return true; |
|---|
| 1962 | + usleep_range(10000, 20000); |
|---|
| 1963 | + } |
|---|
| 1964 | + |
|---|
| 1965 | + return test_bit(state, &vf->vf_states); |
|---|
| 1670 | 1966 | } |
|---|
| 1671 | 1967 | |
|---|
| 1672 | 1968 | /** |
|---|
| .. | .. |
|---|
| 1713 | 2009 | } |
|---|
| 1714 | 2010 | |
|---|
| 1715 | 2011 | /** |
|---|
| 2012 | + * i40e_vc_get_max_frame_size |
|---|
| 2013 | + * @vf: pointer to the VF |
|---|
| 2014 | + * |
|---|
| 2015 | + * Max frame size is determined based on the current port's max frame size and |
|---|
| 2016 | + * whether a port VLAN is configured on this VF. The VF is not aware whether |
|---|
| 2017 | + * it's in a port VLAN so the PF needs to account for this in max frame size |
|---|
| 2018 | + * checks and sending the max frame size to the VF. |
|---|
| 2019 | + **/ |
|---|
| 2020 | +static u16 i40e_vc_get_max_frame_size(struct i40e_vf *vf) |
|---|
| 2021 | +{ |
|---|
| 2022 | + u16 max_frame_size = vf->pf->hw.phy.link_info.max_frame_size; |
|---|
| 2023 | + |
|---|
| 2024 | + if (vf->port_vlan_id) |
|---|
| 2025 | + max_frame_size -= VLAN_HLEN; |
|---|
| 2026 | + |
|---|
| 2027 | + return max_frame_size; |
|---|
| 2028 | +} |
|---|
| 2029 | + |
|---|
| 2030 | +/** |
|---|
| 1716 | 2031 | * i40e_vc_get_vf_resources_msg |
|---|
| 1717 | 2032 | * @vf: pointer to the VF info |
|---|
| 1718 | 2033 | * @msg: pointer to the msg buffer |
|---|
| .. | .. |
|---|
| 1726 | 2041 | i40e_status aq_ret = 0; |
|---|
| 1727 | 2042 | struct i40e_vsi *vsi; |
|---|
| 1728 | 2043 | int num_vsis = 1; |
|---|
| 1729 | | - int len = 0; |
|---|
| 2044 | + size_t len = 0; |
|---|
| 1730 | 2045 | int ret; |
|---|
| 1731 | 2046 | |
|---|
| 1732 | | - if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { |
|---|
| 2047 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_INIT)) { |
|---|
| 1733 | 2048 | aq_ret = I40E_ERR_PARAM; |
|---|
| 1734 | 2049 | goto err; |
|---|
| 1735 | 2050 | } |
|---|
| 1736 | 2051 | |
|---|
| 1737 | | - len = (sizeof(struct virtchnl_vf_resource) + |
|---|
| 1738 | | - sizeof(struct virtchnl_vsi_resource) * num_vsis); |
|---|
| 1739 | | - |
|---|
| 2052 | + len = struct_size(vfres, vsi_res, num_vsis); |
|---|
| 1740 | 2053 | vfres = kzalloc(len, GFP_KERNEL); |
|---|
| 1741 | 2054 | if (!vfres) { |
|---|
| 1742 | 2055 | aq_ret = I40E_ERR_NO_MEMORY; |
|---|
| .. | .. |
|---|
| 1814 | 2127 | vfres->max_vectors = pf->hw.func_caps.num_msix_vectors_vf; |
|---|
| 1815 | 2128 | vfres->rss_key_size = I40E_HKEY_ARRAY_SIZE; |
|---|
| 1816 | 2129 | vfres->rss_lut_size = I40E_VF_HLUT_ARRAY_SIZE; |
|---|
| 2130 | + vfres->max_mtu = i40e_vc_get_max_frame_size(vf); |
|---|
| 1817 | 2131 | |
|---|
| 1818 | 2132 | if (vf->lan_vsi_idx) { |
|---|
| 1819 | 2133 | vfres->vsi_res[0].vsi_id = vf->lan_vsi_id; |
|---|
| .. | .. |
|---|
| 1837 | 2151 | } |
|---|
| 1838 | 2152 | |
|---|
| 1839 | 2153 | /** |
|---|
| 1840 | | - * i40e_vc_reset_vf_msg |
|---|
| 1841 | | - * @vf: pointer to the VF info |
|---|
| 1842 | | - * |
|---|
| 1843 | | - * called from the VF to reset itself, |
|---|
| 1844 | | - * unlike other virtchnl messages, PF driver |
|---|
| 1845 | | - * doesn't send the response back to the VF |
|---|
| 1846 | | - **/ |
|---|
| 1847 | | -static void i40e_vc_reset_vf_msg(struct i40e_vf *vf) |
|---|
| 1848 | | -{ |
|---|
| 1849 | | - if (test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) |
|---|
| 1850 | | - i40e_reset_vf(vf, false); |
|---|
| 1851 | | -} |
|---|
| 1852 | | - |
|---|
| 1853 | | -/** |
|---|
| 1854 | | - * i40e_getnum_vf_vsi_vlan_filters |
|---|
| 1855 | | - * @vsi: pointer to the vsi |
|---|
| 1856 | | - * |
|---|
| 1857 | | - * called to get the number of VLANs offloaded on this VF |
|---|
| 1858 | | - **/ |
|---|
| 1859 | | -static inline int i40e_getnum_vf_vsi_vlan_filters(struct i40e_vsi *vsi) |
|---|
| 1860 | | -{ |
|---|
| 1861 | | - struct i40e_mac_filter *f; |
|---|
| 1862 | | - int num_vlans = 0, bkt; |
|---|
| 1863 | | - |
|---|
| 1864 | | - hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) { |
|---|
| 1865 | | - if (f->vlan >= 0 && f->vlan <= I40E_MAX_VLANID) |
|---|
| 1866 | | - num_vlans++; |
|---|
| 1867 | | - } |
|---|
| 1868 | | - |
|---|
| 1869 | | - return num_vlans; |
|---|
| 1870 | | -} |
|---|
| 1871 | | - |
|---|
| 1872 | | -/** |
|---|
| 1873 | 2154 | * i40e_vc_config_promiscuous_mode_msg |
|---|
| 1874 | 2155 | * @vf: pointer to the VF info |
|---|
| 1875 | 2156 | * @msg: pointer to the msg buffer |
|---|
| 1876 | | - * @msglen: msg length |
|---|
| 1877 | 2157 | * |
|---|
| 1878 | 2158 | * called from the VF to configure the promiscuous mode of |
|---|
| 1879 | 2159 | * VF vsis |
|---|
| 1880 | 2160 | **/ |
|---|
| 1881 | | -static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, |
|---|
| 1882 | | - u8 *msg, u16 msglen) |
|---|
| 2161 | +static int i40e_vc_config_promiscuous_mode_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 1883 | 2162 | { |
|---|
| 1884 | 2163 | struct virtchnl_promisc_info *info = |
|---|
| 1885 | 2164 | (struct virtchnl_promisc_info *)msg; |
|---|
| 1886 | 2165 | struct i40e_pf *pf = vf->pf; |
|---|
| 1887 | | - struct i40e_hw *hw = &pf->hw; |
|---|
| 1888 | | - struct i40e_mac_filter *f; |
|---|
| 1889 | 2166 | i40e_status aq_ret = 0; |
|---|
| 1890 | 2167 | bool allmulti = false; |
|---|
| 1891 | | - struct i40e_vsi *vsi; |
|---|
| 1892 | 2168 | bool alluni = false; |
|---|
| 1893 | | - int aq_err = 0; |
|---|
| 1894 | | - int bkt; |
|---|
| 1895 | 2169 | |
|---|
| 1896 | | - vsi = i40e_find_vsi_from_id(pf, info->vsi_id); |
|---|
| 1897 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 1898 | | - !i40e_vc_isvalid_vsi_id(vf, info->vsi_id) || |
|---|
| 1899 | | - !vsi) { |
|---|
| 2170 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 1900 | 2171 | aq_ret = I40E_ERR_PARAM; |
|---|
| 1901 | | - goto error_param; |
|---|
| 2172 | + goto err_out; |
|---|
| 1902 | 2173 | } |
|---|
| 1903 | 2174 | if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) { |
|---|
| 1904 | 2175 | dev_err(&pf->pdev->dev, |
|---|
| 1905 | 2176 | "Unprivileged VF %d is attempting to configure promiscuous mode\n", |
|---|
| 1906 | 2177 | vf->vf_id); |
|---|
| 1907 | | - /* Lie to the VF on purpose. */ |
|---|
| 2178 | + |
|---|
| 2179 | + /* Lie to the VF on purpose, because this is an error we can |
|---|
| 2180 | + * ignore. Unprivileged VF is not a virtual channel error. |
|---|
| 2181 | + */ |
|---|
| 1908 | 2182 | aq_ret = 0; |
|---|
| 1909 | | - goto error_param; |
|---|
| 2183 | + goto err_out; |
|---|
| 1910 | 2184 | } |
|---|
| 2185 | + |
|---|
| 2186 | + if (info->flags > I40E_MAX_VF_PROMISC_FLAGS) { |
|---|
| 2187 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2188 | + goto err_out; |
|---|
| 2189 | + } |
|---|
| 2190 | + |
|---|
| 2191 | + if (!i40e_vc_isvalid_vsi_id(vf, info->vsi_id)) { |
|---|
| 2192 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2193 | + goto err_out; |
|---|
| 2194 | + } |
|---|
| 2195 | + |
|---|
| 1911 | 2196 | /* Multicast promiscuous handling*/ |
|---|
| 1912 | 2197 | if (info->flags & FLAG_VF_MULTICAST_PROMISC) |
|---|
| 1913 | 2198 | allmulti = true; |
|---|
| 1914 | 2199 | |
|---|
| 1915 | | - if (vf->port_vlan_id) { |
|---|
| 1916 | | - aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, vsi->seid, |
|---|
| 1917 | | - allmulti, |
|---|
| 1918 | | - vf->port_vlan_id, |
|---|
| 1919 | | - NULL); |
|---|
| 1920 | | - } else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) { |
|---|
| 1921 | | - hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) { |
|---|
| 1922 | | - if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID) |
|---|
| 1923 | | - continue; |
|---|
| 1924 | | - aq_ret = i40e_aq_set_vsi_mc_promisc_on_vlan(hw, |
|---|
| 1925 | | - vsi->seid, |
|---|
| 1926 | | - allmulti, |
|---|
| 1927 | | - f->vlan, |
|---|
| 1928 | | - NULL); |
|---|
| 1929 | | - aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1930 | | - if (aq_ret) { |
|---|
| 1931 | | - dev_err(&pf->pdev->dev, |
|---|
| 1932 | | - "Could not add VLAN %d to multicast promiscuous domain err %s aq_err %s\n", |
|---|
| 1933 | | - f->vlan, |
|---|
| 1934 | | - i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1935 | | - i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1936 | | - break; |
|---|
| 1937 | | - } |
|---|
| 1938 | | - } |
|---|
| 1939 | | - } else { |
|---|
| 1940 | | - aq_ret = i40e_aq_set_vsi_multicast_promiscuous(hw, vsi->seid, |
|---|
| 1941 | | - allmulti, NULL); |
|---|
| 1942 | | - aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1943 | | - if (aq_ret) { |
|---|
| 1944 | | - dev_err(&pf->pdev->dev, |
|---|
| 1945 | | - "VF %d failed to set multicast promiscuous mode err %s aq_err %s\n", |
|---|
| 1946 | | - vf->vf_id, |
|---|
| 1947 | | - i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1948 | | - i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1949 | | - goto error_param; |
|---|
| 1950 | | - } |
|---|
| 1951 | | - } |
|---|
| 1952 | | - |
|---|
| 1953 | | - if (!aq_ret) { |
|---|
| 1954 | | - dev_info(&pf->pdev->dev, |
|---|
| 1955 | | - "VF %d successfully set multicast promiscuous mode\n", |
|---|
| 1956 | | - vf->vf_id); |
|---|
| 1957 | | - if (allmulti) |
|---|
| 1958 | | - set_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states); |
|---|
| 1959 | | - else |
|---|
| 1960 | | - clear_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states); |
|---|
| 1961 | | - } |
|---|
| 1962 | | - |
|---|
| 1963 | 2200 | if (info->flags & FLAG_VF_UNICAST_PROMISC) |
|---|
| 1964 | 2201 | alluni = true; |
|---|
| 1965 | | - if (vf->port_vlan_id) { |
|---|
| 1966 | | - aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, vsi->seid, |
|---|
| 1967 | | - alluni, |
|---|
| 1968 | | - vf->port_vlan_id, |
|---|
| 1969 | | - NULL); |
|---|
| 1970 | | - } else if (i40e_getnum_vf_vsi_vlan_filters(vsi)) { |
|---|
| 1971 | | - hash_for_each(vsi->mac_filter_hash, bkt, f, hlist) { |
|---|
| 1972 | | - if (f->vlan < 0 || f->vlan > I40E_MAX_VLANID) |
|---|
| 1973 | | - continue; |
|---|
| 1974 | | - aq_ret = i40e_aq_set_vsi_uc_promisc_on_vlan(hw, |
|---|
| 1975 | | - vsi->seid, |
|---|
| 1976 | | - alluni, |
|---|
| 1977 | | - f->vlan, |
|---|
| 1978 | | - NULL); |
|---|
| 1979 | | - aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1980 | | - if (aq_ret) |
|---|
| 1981 | | - dev_err(&pf->pdev->dev, |
|---|
| 1982 | | - "Could not add VLAN %d to Unicast promiscuous domain err %s aq_err %s\n", |
|---|
| 1983 | | - f->vlan, |
|---|
| 1984 | | - i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1985 | | - i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1986 | | - } |
|---|
| 1987 | | - } else { |
|---|
| 1988 | | - aq_ret = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid, |
|---|
| 1989 | | - alluni, NULL, |
|---|
| 1990 | | - true); |
|---|
| 1991 | | - aq_err = pf->hw.aq.asq_last_status; |
|---|
| 1992 | | - if (aq_ret) { |
|---|
| 1993 | | - dev_err(&pf->pdev->dev, |
|---|
| 1994 | | - "VF %d failed to set unicast promiscuous mode %8.8x err %s aq_err %s\n", |
|---|
| 1995 | | - vf->vf_id, info->flags, |
|---|
| 1996 | | - i40e_stat_str(&pf->hw, aq_ret), |
|---|
| 1997 | | - i40e_aq_str(&pf->hw, aq_err)); |
|---|
| 1998 | | - goto error_param; |
|---|
| 1999 | | - } |
|---|
| 2000 | | - } |
|---|
| 2202 | + aq_ret = i40e_config_vf_promiscuous_mode(vf, info->vsi_id, allmulti, |
|---|
| 2203 | + alluni); |
|---|
| 2204 | + if (aq_ret) |
|---|
| 2205 | + goto err_out; |
|---|
| 2001 | 2206 | |
|---|
| 2002 | | - if (!aq_ret) { |
|---|
| 2207 | + if (allmulti) { |
|---|
| 2208 | + if (!test_and_set_bit(I40E_VF_STATE_MC_PROMISC, |
|---|
| 2209 | + &vf->vf_states)) |
|---|
| 2210 | + dev_info(&pf->pdev->dev, |
|---|
| 2211 | + "VF %d successfully set multicast promiscuous mode\n", |
|---|
| 2212 | + vf->vf_id); |
|---|
| 2213 | + } else if (test_and_clear_bit(I40E_VF_STATE_MC_PROMISC, |
|---|
| 2214 | + &vf->vf_states)) |
|---|
| 2003 | 2215 | dev_info(&pf->pdev->dev, |
|---|
| 2004 | | - "VF %d successfully set unicast promiscuous mode\n", |
|---|
| 2216 | + "VF %d successfully unset multicast promiscuous mode\n", |
|---|
| 2005 | 2217 | vf->vf_id); |
|---|
| 2006 | | - if (alluni) |
|---|
| 2007 | | - set_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states); |
|---|
| 2008 | | - else |
|---|
| 2009 | | - clear_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states); |
|---|
| 2010 | | - } |
|---|
| 2011 | 2218 | |
|---|
| 2012 | | -error_param: |
|---|
| 2219 | + if (alluni) { |
|---|
| 2220 | + if (!test_and_set_bit(I40E_VF_STATE_UC_PROMISC, |
|---|
| 2221 | + &vf->vf_states)) |
|---|
| 2222 | + dev_info(&pf->pdev->dev, |
|---|
| 2223 | + "VF %d successfully set unicast promiscuous mode\n", |
|---|
| 2224 | + vf->vf_id); |
|---|
| 2225 | + } else if (test_and_clear_bit(I40E_VF_STATE_UC_PROMISC, |
|---|
| 2226 | + &vf->vf_states)) |
|---|
| 2227 | + dev_info(&pf->pdev->dev, |
|---|
| 2228 | + "VF %d successfully unset unicast promiscuous mode\n", |
|---|
| 2229 | + vf->vf_id); |
|---|
| 2230 | + |
|---|
| 2231 | +err_out: |
|---|
| 2013 | 2232 | /* send the response to the VF */ |
|---|
| 2014 | 2233 | return i40e_vc_send_resp_to_vf(vf, |
|---|
| 2015 | 2234 | VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, |
|---|
| .. | .. |
|---|
| 2020 | 2239 | * i40e_vc_config_queues_msg |
|---|
| 2021 | 2240 | * @vf: pointer to the VF info |
|---|
| 2022 | 2241 | * @msg: pointer to the msg buffer |
|---|
| 2023 | | - * @msglen: msg length |
|---|
| 2024 | 2242 | * |
|---|
| 2025 | 2243 | * called from the VF to configure the rx/tx |
|---|
| 2026 | 2244 | * queues |
|---|
| 2027 | 2245 | **/ |
|---|
| 2028 | | -static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2246 | +static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2029 | 2247 | { |
|---|
| 2030 | 2248 | struct virtchnl_vsi_queue_config_info *qci = |
|---|
| 2031 | 2249 | (struct virtchnl_vsi_queue_config_info *)msg; |
|---|
| 2032 | 2250 | struct virtchnl_queue_pair_info *qpi; |
|---|
| 2033 | | - struct i40e_pf *pf = vf->pf; |
|---|
| 2034 | 2251 | u16 vsi_id, vsi_queue_id = 0; |
|---|
| 2252 | + struct i40e_pf *pf = vf->pf; |
|---|
| 2035 | 2253 | i40e_status aq_ret = 0; |
|---|
| 2036 | 2254 | int i, j = 0, idx = 0; |
|---|
| 2255 | + struct i40e_vsi *vsi; |
|---|
| 2256 | + u16 num_qps_all = 0; |
|---|
| 2257 | + |
|---|
| 2258 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 2259 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2260 | + goto error_param; |
|---|
| 2261 | + } |
|---|
| 2262 | + |
|---|
| 2263 | + if (!i40e_vc_isvalid_vsi_id(vf, qci->vsi_id)) { |
|---|
| 2264 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2265 | + goto error_param; |
|---|
| 2266 | + } |
|---|
| 2267 | + |
|---|
| 2268 | + if (qci->num_queue_pairs > I40E_MAX_VF_QUEUES) { |
|---|
| 2269 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2270 | + goto error_param; |
|---|
| 2271 | + } |
|---|
| 2272 | + |
|---|
| 2273 | + if (vf->adq_enabled) { |
|---|
| 2274 | + for (i = 0; i < vf->num_tc; i++) |
|---|
| 2275 | + num_qps_all += vf->ch[i].num_qps; |
|---|
| 2276 | + if (num_qps_all != qci->num_queue_pairs) { |
|---|
| 2277 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2278 | + goto error_param; |
|---|
| 2279 | + } |
|---|
| 2280 | + } |
|---|
| 2037 | 2281 | |
|---|
| 2038 | 2282 | vsi_id = qci->vsi_id; |
|---|
| 2039 | | - |
|---|
| 2040 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 2041 | | - aq_ret = I40E_ERR_PARAM; |
|---|
| 2042 | | - goto error_param; |
|---|
| 2043 | | - } |
|---|
| 2044 | | - |
|---|
| 2045 | | - if (!i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 2046 | | - aq_ret = I40E_ERR_PARAM; |
|---|
| 2047 | | - goto error_param; |
|---|
| 2048 | | - } |
|---|
| 2049 | 2283 | |
|---|
| 2050 | 2284 | for (i = 0; i < qci->num_queue_pairs; i++) { |
|---|
| 2051 | 2285 | qpi = &qci->qpair[i]; |
|---|
| 2052 | 2286 | |
|---|
| 2053 | 2287 | if (!vf->adq_enabled) { |
|---|
| 2288 | + if (!i40e_vc_isvalid_queue_id(vf, vsi_id, |
|---|
| 2289 | + qpi->txq.queue_id)) { |
|---|
| 2290 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2291 | + goto error_param; |
|---|
| 2292 | + } |
|---|
| 2293 | + |
|---|
| 2054 | 2294 | vsi_queue_id = qpi->txq.queue_id; |
|---|
| 2055 | 2295 | |
|---|
| 2056 | 2296 | if (qpi->txq.vsi_id != qci->vsi_id || |
|---|
| .. | .. |
|---|
| 2061 | 2301 | } |
|---|
| 2062 | 2302 | } |
|---|
| 2063 | 2303 | |
|---|
| 2064 | | - if (!i40e_vc_isvalid_queue_id(vf, vsi_id, vsi_queue_id)) { |
|---|
| 2065 | | - aq_ret = I40E_ERR_PARAM; |
|---|
| 2066 | | - goto error_param; |
|---|
| 2304 | + if (vf->adq_enabled) { |
|---|
| 2305 | + if (idx >= ARRAY_SIZE(vf->ch)) { |
|---|
| 2306 | + aq_ret = I40E_ERR_NO_AVAILABLE_VSI; |
|---|
| 2307 | + goto error_param; |
|---|
| 2308 | + } |
|---|
| 2309 | + vsi_id = vf->ch[idx].vsi_id; |
|---|
| 2067 | 2310 | } |
|---|
| 2068 | 2311 | |
|---|
| 2069 | 2312 | if (i40e_config_vsi_rx_queue(vf, vsi_id, vsi_queue_id, |
|---|
| .. | .. |
|---|
| 2078 | 2321 | * VF does not know about these additional VSIs and all |
|---|
| 2079 | 2322 | * it cares is about its own queues. PF configures these queues |
|---|
| 2080 | 2323 | * to its appropriate VSIs based on TC mapping |
|---|
| 2081 | | - **/ |
|---|
| 2324 | + */ |
|---|
| 2082 | 2325 | if (vf->adq_enabled) { |
|---|
| 2326 | + if (idx >= ARRAY_SIZE(vf->ch)) { |
|---|
| 2327 | + aq_ret = I40E_ERR_NO_AVAILABLE_VSI; |
|---|
| 2328 | + goto error_param; |
|---|
| 2329 | + } |
|---|
| 2083 | 2330 | if (j == (vf->ch[idx].num_qps - 1)) { |
|---|
| 2084 | 2331 | idx++; |
|---|
| 2085 | 2332 | j = 0; /* resetting the queue count */ |
|---|
| .. | .. |
|---|
| 2088 | 2335 | j++; |
|---|
| 2089 | 2336 | vsi_queue_id++; |
|---|
| 2090 | 2337 | } |
|---|
| 2091 | | - vsi_id = vf->ch[idx].vsi_id; |
|---|
| 2092 | 2338 | } |
|---|
| 2093 | 2339 | } |
|---|
| 2094 | 2340 | /* set vsi num_queue_pairs in use to num configured by VF */ |
|---|
| .. | .. |
|---|
| 2096 | 2342 | pf->vsi[vf->lan_vsi_idx]->num_queue_pairs = |
|---|
| 2097 | 2343 | qci->num_queue_pairs; |
|---|
| 2098 | 2344 | } else { |
|---|
| 2099 | | - for (i = 0; i < vf->num_tc; i++) |
|---|
| 2100 | | - pf->vsi[vf->ch[i].vsi_idx]->num_queue_pairs = |
|---|
| 2101 | | - vf->ch[i].num_qps; |
|---|
| 2345 | + for (i = 0; i < vf->num_tc; i++) { |
|---|
| 2346 | + vsi = pf->vsi[vf->ch[i].vsi_idx]; |
|---|
| 2347 | + vsi->num_queue_pairs = vf->ch[i].num_qps; |
|---|
| 2348 | + |
|---|
| 2349 | + if (i40e_update_adq_vsi_queues(vsi, i)) { |
|---|
| 2350 | + aq_ret = I40E_ERR_CONFIG; |
|---|
| 2351 | + goto error_param; |
|---|
| 2352 | + } |
|---|
| 2353 | + } |
|---|
| 2102 | 2354 | } |
|---|
| 2103 | 2355 | |
|---|
| 2104 | 2356 | error_param: |
|---|
| .. | .. |
|---|
| 2108 | 2360 | } |
|---|
| 2109 | 2361 | |
|---|
| 2110 | 2362 | /** |
|---|
| 2111 | | - * i40e_validate_queue_map |
|---|
| 2363 | + * i40e_validate_queue_map - check queue map is valid |
|---|
| 2364 | + * @vf: the VF structure pointer |
|---|
| 2112 | 2365 | * @vsi_id: vsi id |
|---|
| 2113 | 2366 | * @queuemap: Tx or Rx queue map |
|---|
| 2114 | 2367 | * |
|---|
| .. | .. |
|---|
| 2138 | 2391 | * i40e_vc_config_irq_map_msg |
|---|
| 2139 | 2392 | * @vf: pointer to the VF info |
|---|
| 2140 | 2393 | * @msg: pointer to the msg buffer |
|---|
| 2141 | | - * @msglen: msg length |
|---|
| 2142 | 2394 | * |
|---|
| 2143 | 2395 | * called from the VF to configure the irq to |
|---|
| 2144 | 2396 | * queue map |
|---|
| 2145 | 2397 | **/ |
|---|
| 2146 | | -static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2398 | +static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2147 | 2399 | { |
|---|
| 2148 | 2400 | struct virtchnl_irq_map_info *irqmap_info = |
|---|
| 2149 | 2401 | (struct virtchnl_irq_map_info *)msg; |
|---|
| 2150 | 2402 | struct virtchnl_vector_map *map; |
|---|
| 2151 | | - u16 vsi_id, vector_id; |
|---|
| 2403 | + u16 vsi_id; |
|---|
| 2152 | 2404 | i40e_status aq_ret = 0; |
|---|
| 2153 | 2405 | int i; |
|---|
| 2154 | 2406 | |
|---|
| 2155 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 2407 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 2408 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2409 | + goto error_param; |
|---|
| 2410 | + } |
|---|
| 2411 | + |
|---|
| 2412 | + if (irqmap_info->num_vectors > |
|---|
| 2413 | + vf->pf->hw.func_caps.num_msix_vectors_vf) { |
|---|
| 2156 | 2414 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2157 | 2415 | goto error_param; |
|---|
| 2158 | 2416 | } |
|---|
| 2159 | 2417 | |
|---|
| 2160 | 2418 | for (i = 0; i < irqmap_info->num_vectors; i++) { |
|---|
| 2161 | 2419 | map = &irqmap_info->vecmap[i]; |
|---|
| 2162 | | - vector_id = map->vector_id; |
|---|
| 2163 | | - vsi_id = map->vsi_id; |
|---|
| 2164 | 2420 | /* validate msg params */ |
|---|
| 2165 | | - if (!i40e_vc_isvalid_vector_id(vf, vector_id) || |
|---|
| 2166 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 2421 | + if (!i40e_vc_isvalid_vector_id(vf, map->vector_id) || |
|---|
| 2422 | + !i40e_vc_isvalid_vsi_id(vf, map->vsi_id)) { |
|---|
| 2167 | 2423 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2168 | 2424 | goto error_param; |
|---|
| 2169 | 2425 | } |
|---|
| 2426 | + vsi_id = map->vsi_id; |
|---|
| 2170 | 2427 | |
|---|
| 2171 | 2428 | if (i40e_validate_queue_map(vf, vsi_id, map->rxq_map)) { |
|---|
| 2172 | 2429 | aq_ret = I40E_ERR_PARAM; |
|---|
| .. | .. |
|---|
| 2232 | 2489 | } |
|---|
| 2233 | 2490 | |
|---|
| 2234 | 2491 | /** |
|---|
| 2492 | + * i40e_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTHCHNL |
|---|
| 2493 | + * @vqs: virtchnl_queue_select structure containing bitmaps to validate |
|---|
| 2494 | + * |
|---|
| 2495 | + * Returns true if validation was successful, else false. |
|---|
| 2496 | + */ |
|---|
| 2497 | +static bool i40e_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs) |
|---|
| 2498 | +{ |
|---|
| 2499 | + if ((!vqs->rx_queues && !vqs->tx_queues) || |
|---|
| 2500 | + vqs->rx_queues >= BIT(I40E_MAX_VF_QUEUES) || |
|---|
| 2501 | + vqs->tx_queues >= BIT(I40E_MAX_VF_QUEUES)) |
|---|
| 2502 | + return false; |
|---|
| 2503 | + |
|---|
| 2504 | + return true; |
|---|
| 2505 | +} |
|---|
| 2506 | + |
|---|
| 2507 | +/** |
|---|
| 2235 | 2508 | * i40e_vc_enable_queues_msg |
|---|
| 2236 | 2509 | * @vf: pointer to the VF info |
|---|
| 2237 | 2510 | * @msg: pointer to the msg buffer |
|---|
| 2238 | | - * @msglen: msg length |
|---|
| 2239 | 2511 | * |
|---|
| 2240 | 2512 | * called from the VF to enable all or specific queue(s) |
|---|
| 2241 | 2513 | **/ |
|---|
| 2242 | | -static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2514 | +static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2243 | 2515 | { |
|---|
| 2244 | 2516 | struct virtchnl_queue_select *vqs = |
|---|
| 2245 | 2517 | (struct virtchnl_queue_select *)msg; |
|---|
| 2246 | 2518 | struct i40e_pf *pf = vf->pf; |
|---|
| 2247 | | - u16 vsi_id = vqs->vsi_id; |
|---|
| 2248 | 2519 | i40e_status aq_ret = 0; |
|---|
| 2249 | 2520 | int i; |
|---|
| 2250 | 2521 | |
|---|
| .. | .. |
|---|
| 2253 | 2524 | goto error_param; |
|---|
| 2254 | 2525 | } |
|---|
| 2255 | 2526 | |
|---|
| 2256 | | - if (!i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 2527 | + if (!i40e_vc_isvalid_vsi_id(vf, vqs->vsi_id)) { |
|---|
| 2257 | 2528 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2258 | 2529 | goto error_param; |
|---|
| 2259 | 2530 | } |
|---|
| 2260 | 2531 | |
|---|
| 2261 | | - if ((0 == vqs->rx_queues) && (0 == vqs->tx_queues)) { |
|---|
| 2532 | + if (!i40e_vc_validate_vqs_bitmaps(vqs)) { |
|---|
| 2262 | 2533 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2263 | 2534 | goto error_param; |
|---|
| 2264 | 2535 | } |
|---|
| .. | .. |
|---|
| 2294 | 2565 | * i40e_vc_disable_queues_msg |
|---|
| 2295 | 2566 | * @vf: pointer to the VF info |
|---|
| 2296 | 2567 | * @msg: pointer to the msg buffer |
|---|
| 2297 | | - * @msglen: msg length |
|---|
| 2298 | 2568 | * |
|---|
| 2299 | 2569 | * called from the VF to disable all or specific |
|---|
| 2300 | 2570 | * queue(s) |
|---|
| 2301 | 2571 | **/ |
|---|
| 2302 | | -static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2572 | +static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2303 | 2573 | { |
|---|
| 2304 | 2574 | struct virtchnl_queue_select *vqs = |
|---|
| 2305 | 2575 | (struct virtchnl_queue_select *)msg; |
|---|
| 2306 | 2576 | struct i40e_pf *pf = vf->pf; |
|---|
| 2307 | 2577 | i40e_status aq_ret = 0; |
|---|
| 2308 | 2578 | |
|---|
| 2309 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 2579 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 2310 | 2580 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2311 | 2581 | goto error_param; |
|---|
| 2312 | 2582 | } |
|---|
| .. | .. |
|---|
| 2316 | 2586 | goto error_param; |
|---|
| 2317 | 2587 | } |
|---|
| 2318 | 2588 | |
|---|
| 2319 | | - if ((0 == vqs->rx_queues) && (0 == vqs->tx_queues)) { |
|---|
| 2589 | + if (!i40e_vc_validate_vqs_bitmaps(vqs)) { |
|---|
| 2320 | 2590 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2321 | 2591 | goto error_param; |
|---|
| 2322 | 2592 | } |
|---|
| .. | .. |
|---|
| 2395 | 2665 | * i40e_vc_request_queues_msg |
|---|
| 2396 | 2666 | * @vf: pointer to the VF info |
|---|
| 2397 | 2667 | * @msg: pointer to the msg buffer |
|---|
| 2398 | | - * @msglen: msg length |
|---|
| 2399 | 2668 | * |
|---|
| 2400 | 2669 | * VFs get a default number of queues but can use this message to request a |
|---|
| 2401 | 2670 | * different number. If the request is successful, PF will reset the VF and |
|---|
| 2402 | 2671 | * return 0. If unsuccessful, PF will send message informing VF of number of |
|---|
| 2403 | 2672 | * available queues and return result of sending VF a message. |
|---|
| 2404 | 2673 | **/ |
|---|
| 2405 | | -static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg, int msglen) |
|---|
| 2674 | +static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2406 | 2675 | { |
|---|
| 2407 | 2676 | struct virtchnl_vf_res_request *vfres = |
|---|
| 2408 | 2677 | (struct virtchnl_vf_res_request *)msg; |
|---|
| 2409 | | - int req_pairs = vfres->num_queue_pairs; |
|---|
| 2410 | | - int cur_pairs = vf->num_queue_pairs; |
|---|
| 2678 | + u16 req_pairs = vfres->num_queue_pairs; |
|---|
| 2679 | + u8 cur_pairs = vf->num_queue_pairs; |
|---|
| 2411 | 2680 | struct i40e_pf *pf = vf->pf; |
|---|
| 2412 | 2681 | |
|---|
| 2413 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) |
|---|
| 2682 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) |
|---|
| 2414 | 2683 | return -EINVAL; |
|---|
| 2415 | 2684 | |
|---|
| 2416 | | - if (req_pairs <= 0) { |
|---|
| 2417 | | - dev_err(&pf->pdev->dev, |
|---|
| 2418 | | - "VF %d tried to request %d queues. Ignoring.\n", |
|---|
| 2419 | | - vf->vf_id, req_pairs); |
|---|
| 2420 | | - } else if (req_pairs > I40E_MAX_VF_QUEUES) { |
|---|
| 2685 | + if (req_pairs > I40E_MAX_VF_QUEUES) { |
|---|
| 2421 | 2686 | dev_err(&pf->pdev->dev, |
|---|
| 2422 | 2687 | "VF %d tried to request more than %d queues.\n", |
|---|
| 2423 | 2688 | vf->vf_id, |
|---|
| .. | .. |
|---|
| 2439 | 2704 | } else { |
|---|
| 2440 | 2705 | /* successful request */ |
|---|
| 2441 | 2706 | vf->num_req_queues = req_pairs; |
|---|
| 2442 | | - i40e_vc_notify_vf_reset(vf); |
|---|
| 2443 | | - i40e_reset_vf(vf, false); |
|---|
| 2707 | + i40e_vc_reset_vf(vf, true); |
|---|
| 2444 | 2708 | return 0; |
|---|
| 2445 | 2709 | } |
|---|
| 2446 | 2710 | |
|---|
| .. | .. |
|---|
| 2452 | 2716 | * i40e_vc_get_stats_msg |
|---|
| 2453 | 2717 | * @vf: pointer to the VF info |
|---|
| 2454 | 2718 | * @msg: pointer to the msg buffer |
|---|
| 2455 | | - * @msglen: msg length |
|---|
| 2456 | 2719 | * |
|---|
| 2457 | 2720 | * called from the VF to get vsi stats |
|---|
| 2458 | 2721 | **/ |
|---|
| 2459 | | -static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2722 | +static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2460 | 2723 | { |
|---|
| 2461 | 2724 | struct virtchnl_queue_select *vqs = |
|---|
| 2462 | 2725 | (struct virtchnl_queue_select *)msg; |
|---|
| .. | .. |
|---|
| 2467 | 2730 | |
|---|
| 2468 | 2731 | memset(&stats, 0, sizeof(struct i40e_eth_stats)); |
|---|
| 2469 | 2732 | |
|---|
| 2470 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 2733 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 2471 | 2734 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2472 | 2735 | goto error_param; |
|---|
| 2473 | 2736 | } |
|---|
| .. | .. |
|---|
| 2495 | 2758 | * MAC filters: 16 for multicast, 1 for MAC, 1 for broadcast |
|---|
| 2496 | 2759 | */ |
|---|
| 2497 | 2760 | #define I40E_VC_MAX_MAC_ADDR_PER_VF (16 + 1 + 1) |
|---|
| 2498 | | -#define I40E_VC_MAX_VLAN_PER_VF 8 |
|---|
| 2761 | +#define I40E_VC_MAX_VLAN_PER_VF 16 |
|---|
| 2499 | 2762 | |
|---|
| 2500 | 2763 | /** |
|---|
| 2501 | 2764 | * i40e_check_vf_permission |
|---|
| .. | .. |
|---|
| 2518 | 2781 | struct virtchnl_ether_addr_list *al) |
|---|
| 2519 | 2782 | { |
|---|
| 2520 | 2783 | struct i40e_pf *pf = vf->pf; |
|---|
| 2784 | + struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 2785 | + int mac2add_cnt = 0; |
|---|
| 2521 | 2786 | int i; |
|---|
| 2522 | 2787 | |
|---|
| 2523 | | - /* If this VF is not privileged, then we can't add more than a limited |
|---|
| 2524 | | - * number of addresses. Check to make sure that the additions do not |
|---|
| 2525 | | - * push us over the limit. |
|---|
| 2526 | | - */ |
|---|
| 2527 | | - if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) && |
|---|
| 2528 | | - (vf->num_mac + al->num_elements) > I40E_VC_MAX_MAC_ADDR_PER_VF) { |
|---|
| 2529 | | - dev_err(&pf->pdev->dev, |
|---|
| 2530 | | - "Cannot add more MAC addresses, VF is not trusted, switch the VF to trusted to add more functionality\n"); |
|---|
| 2531 | | - return -EPERM; |
|---|
| 2532 | | - } |
|---|
| 2533 | | - |
|---|
| 2534 | 2788 | for (i = 0; i < al->num_elements; i++) { |
|---|
| 2789 | + struct i40e_mac_filter *f; |
|---|
| 2535 | 2790 | u8 *addr = al->list[i].addr; |
|---|
| 2536 | 2791 | |
|---|
| 2537 | 2792 | if (is_broadcast_ether_addr(addr) || |
|---|
| .. | .. |
|---|
| 2552 | 2807 | !is_multicast_ether_addr(addr) && vf->pf_set_mac && |
|---|
| 2553 | 2808 | !ether_addr_equal(addr, vf->default_lan_addr.addr)) { |
|---|
| 2554 | 2809 | dev_err(&pf->pdev->dev, |
|---|
| 2555 | | - "VF attempting to override administratively set MAC address, reload the VF driver to resume normal operation\n"); |
|---|
| 2810 | + "VF attempting to override administratively set MAC address, bring down and up the VF interface to resume normal operation\n"); |
|---|
| 2556 | 2811 | return -EPERM; |
|---|
| 2557 | 2812 | } |
|---|
| 2813 | + |
|---|
| 2814 | + /*count filters that really will be added*/ |
|---|
| 2815 | + f = i40e_find_mac(vsi, addr); |
|---|
| 2816 | + if (!f) |
|---|
| 2817 | + ++mac2add_cnt; |
|---|
| 2558 | 2818 | } |
|---|
| 2559 | 2819 | |
|---|
| 2820 | + /* If this VF is not privileged, then we can't add more than a limited |
|---|
| 2821 | + * number of addresses. Check to make sure that the additions do not |
|---|
| 2822 | + * push us over the limit. |
|---|
| 2823 | + */ |
|---|
| 2824 | + if (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps) && |
|---|
| 2825 | + (i40e_count_filters(vsi) + mac2add_cnt) > |
|---|
| 2826 | + I40E_VC_MAX_MAC_ADDR_PER_VF) { |
|---|
| 2827 | + dev_err(&pf->pdev->dev, |
|---|
| 2828 | + "Cannot add more MAC addresses, VF is not trusted, switch the VF to trusted to add more functionality\n"); |
|---|
| 2829 | + return -EPERM; |
|---|
| 2830 | + } |
|---|
| 2560 | 2831 | return 0; |
|---|
| 2561 | 2832 | } |
|---|
| 2562 | 2833 | |
|---|
| .. | .. |
|---|
| 2564 | 2835 | * i40e_vc_add_mac_addr_msg |
|---|
| 2565 | 2836 | * @vf: pointer to the VF info |
|---|
| 2566 | 2837 | * @msg: pointer to the msg buffer |
|---|
| 2567 | | - * @msglen: msg length |
|---|
| 2568 | 2838 | * |
|---|
| 2569 | 2839 | * add guest mac address filter |
|---|
| 2570 | 2840 | **/ |
|---|
| 2571 | | -static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2841 | +static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2572 | 2842 | { |
|---|
| 2573 | 2843 | struct virtchnl_ether_addr_list *al = |
|---|
| 2574 | 2844 | (struct virtchnl_ether_addr_list *)msg; |
|---|
| 2575 | 2845 | struct i40e_pf *pf = vf->pf; |
|---|
| 2576 | 2846 | struct i40e_vsi *vsi = NULL; |
|---|
| 2577 | | - u16 vsi_id = al->vsi_id; |
|---|
| 2578 | 2847 | i40e_status ret = 0; |
|---|
| 2579 | 2848 | int i; |
|---|
| 2580 | 2849 | |
|---|
| 2581 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2582 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 2850 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || |
|---|
| 2851 | + !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) { |
|---|
| 2583 | 2852 | ret = I40E_ERR_PARAM; |
|---|
| 2584 | 2853 | goto error_param; |
|---|
| 2585 | 2854 | } |
|---|
| .. | .. |
|---|
| 2612 | 2881 | ret = I40E_ERR_PARAM; |
|---|
| 2613 | 2882 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 2614 | 2883 | goto error_param; |
|---|
| 2615 | | - } else { |
|---|
| 2616 | | - vf->num_mac++; |
|---|
| 2617 | 2884 | } |
|---|
| 2885 | + if (is_valid_ether_addr(al->list[i].addr) && |
|---|
| 2886 | + is_zero_ether_addr(vf->default_lan_addr.addr)) |
|---|
| 2887 | + ether_addr_copy(vf->default_lan_addr.addr, |
|---|
| 2888 | + al->list[i].addr); |
|---|
| 2618 | 2889 | } |
|---|
| 2619 | 2890 | } |
|---|
| 2620 | 2891 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| .. | .. |
|---|
| 2627 | 2898 | |
|---|
| 2628 | 2899 | error_param: |
|---|
| 2629 | 2900 | /* send the response to the VF */ |
|---|
| 2630 | | - return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR, |
|---|
| 2631 | | - ret); |
|---|
| 2901 | + return i40e_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR, |
|---|
| 2902 | + ret, NULL, 0); |
|---|
| 2632 | 2903 | } |
|---|
| 2633 | 2904 | |
|---|
| 2634 | 2905 | /** |
|---|
| 2635 | 2906 | * i40e_vc_del_mac_addr_msg |
|---|
| 2636 | 2907 | * @vf: pointer to the VF info |
|---|
| 2637 | 2908 | * @msg: pointer to the msg buffer |
|---|
| 2638 | | - * @msglen: msg length |
|---|
| 2639 | 2909 | * |
|---|
| 2640 | 2910 | * remove guest mac address filter |
|---|
| 2641 | 2911 | **/ |
|---|
| 2642 | | -static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2912 | +static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2643 | 2913 | { |
|---|
| 2644 | 2914 | struct virtchnl_ether_addr_list *al = |
|---|
| 2645 | 2915 | (struct virtchnl_ether_addr_list *)msg; |
|---|
| 2916 | + bool was_unimac_deleted = false; |
|---|
| 2646 | 2917 | struct i40e_pf *pf = vf->pf; |
|---|
| 2647 | 2918 | struct i40e_vsi *vsi = NULL; |
|---|
| 2648 | | - u16 vsi_id = al->vsi_id; |
|---|
| 2649 | 2919 | i40e_status ret = 0; |
|---|
| 2650 | 2920 | int i; |
|---|
| 2651 | 2921 | |
|---|
| 2652 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2653 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 2922 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || |
|---|
| 2923 | + !i40e_vc_isvalid_vsi_id(vf, al->vsi_id)) { |
|---|
| 2654 | 2924 | ret = I40E_ERR_PARAM; |
|---|
| 2655 | 2925 | goto error_param; |
|---|
| 2656 | 2926 | } |
|---|
| .. | .. |
|---|
| 2663 | 2933 | ret = I40E_ERR_INVALID_MAC_ADDR; |
|---|
| 2664 | 2934 | goto error_param; |
|---|
| 2665 | 2935 | } |
|---|
| 2666 | | - |
|---|
| 2667 | | - if (vf->pf_set_mac && |
|---|
| 2668 | | - ether_addr_equal(al->list[i].addr, |
|---|
| 2669 | | - vf->default_lan_addr.addr)) { |
|---|
| 2670 | | - dev_err(&pf->pdev->dev, |
|---|
| 2671 | | - "MAC addr %pM has been set by PF, cannot delete it for VF %d, reset VF to change MAC addr\n", |
|---|
| 2672 | | - vf->default_lan_addr.addr, vf->vf_id); |
|---|
| 2673 | | - ret = I40E_ERR_PARAM; |
|---|
| 2674 | | - goto error_param; |
|---|
| 2675 | | - } |
|---|
| 2936 | + if (ether_addr_equal(al->list[i].addr, vf->default_lan_addr.addr)) |
|---|
| 2937 | + was_unimac_deleted = true; |
|---|
| 2676 | 2938 | } |
|---|
| 2677 | 2939 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 2678 | 2940 | |
|---|
| .. | .. |
|---|
| 2683 | 2945 | ret = I40E_ERR_INVALID_MAC_ADDR; |
|---|
| 2684 | 2946 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 2685 | 2947 | goto error_param; |
|---|
| 2686 | | - } else { |
|---|
| 2687 | | - vf->num_mac--; |
|---|
| 2688 | 2948 | } |
|---|
| 2689 | 2949 | |
|---|
| 2690 | 2950 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| .. | .. |
|---|
| 2695 | 2955 | dev_err(&pf->pdev->dev, "Unable to program VF %d MAC filters, error %d\n", |
|---|
| 2696 | 2956 | vf->vf_id, ret); |
|---|
| 2697 | 2957 | |
|---|
| 2958 | + if (vf->trusted && was_unimac_deleted) { |
|---|
| 2959 | + struct i40e_mac_filter *f; |
|---|
| 2960 | + struct hlist_node *h; |
|---|
| 2961 | + u8 *macaddr = NULL; |
|---|
| 2962 | + int bkt; |
|---|
| 2963 | + |
|---|
| 2964 | + /* set last unicast mac address as default */ |
|---|
| 2965 | + spin_lock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 2966 | + hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist) { |
|---|
| 2967 | + if (is_valid_ether_addr(f->macaddr)) |
|---|
| 2968 | + macaddr = f->macaddr; |
|---|
| 2969 | + } |
|---|
| 2970 | + if (macaddr) |
|---|
| 2971 | + ether_addr_copy(vf->default_lan_addr.addr, macaddr); |
|---|
| 2972 | + spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 2973 | + } |
|---|
| 2698 | 2974 | error_param: |
|---|
| 2699 | 2975 | /* send the response to the VF */ |
|---|
| 2700 | | - return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_ETH_ADDR, |
|---|
| 2701 | | - ret); |
|---|
| 2976 | + return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_ETH_ADDR, ret); |
|---|
| 2702 | 2977 | } |
|---|
| 2703 | 2978 | |
|---|
| 2704 | 2979 | /** |
|---|
| 2705 | 2980 | * i40e_vc_add_vlan_msg |
|---|
| 2706 | 2981 | * @vf: pointer to the VF info |
|---|
| 2707 | 2982 | * @msg: pointer to the msg buffer |
|---|
| 2708 | | - * @msglen: msg length |
|---|
| 2709 | 2983 | * |
|---|
| 2710 | 2984 | * program guest vlan id |
|---|
| 2711 | 2985 | **/ |
|---|
| 2712 | | -static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 2986 | +static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2713 | 2987 | { |
|---|
| 2714 | 2988 | struct virtchnl_vlan_filter_list *vfl = |
|---|
| 2715 | 2989 | (struct virtchnl_vlan_filter_list *)msg; |
|---|
| 2716 | 2990 | struct i40e_pf *pf = vf->pf; |
|---|
| 2717 | 2991 | struct i40e_vsi *vsi = NULL; |
|---|
| 2718 | | - u16 vsi_id = vfl->vsi_id; |
|---|
| 2719 | 2992 | i40e_status aq_ret = 0; |
|---|
| 2720 | 2993 | int i; |
|---|
| 2721 | 2994 | |
|---|
| .. | .. |
|---|
| 2726 | 2999 | goto error_param; |
|---|
| 2727 | 3000 | } |
|---|
| 2728 | 3001 | if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2729 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 3002 | + !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) { |
|---|
| 2730 | 3003 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2731 | 3004 | goto error_param; |
|---|
| 2732 | 3005 | } |
|---|
| .. | .. |
|---|
| 2778 | 3051 | * i40e_vc_remove_vlan_msg |
|---|
| 2779 | 3052 | * @vf: pointer to the VF info |
|---|
| 2780 | 3053 | * @msg: pointer to the msg buffer |
|---|
| 2781 | | - * @msglen: msg length |
|---|
| 2782 | 3054 | * |
|---|
| 2783 | 3055 | * remove programmed guest vlan id |
|---|
| 2784 | 3056 | **/ |
|---|
| 2785 | | -static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 3057 | +static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg) |
|---|
| 2786 | 3058 | { |
|---|
| 2787 | 3059 | struct virtchnl_vlan_filter_list *vfl = |
|---|
| 2788 | 3060 | (struct virtchnl_vlan_filter_list *)msg; |
|---|
| 2789 | 3061 | struct i40e_pf *pf = vf->pf; |
|---|
| 2790 | 3062 | struct i40e_vsi *vsi = NULL; |
|---|
| 2791 | | - u16 vsi_id = vfl->vsi_id; |
|---|
| 2792 | 3063 | i40e_status aq_ret = 0; |
|---|
| 2793 | 3064 | int i; |
|---|
| 2794 | 3065 | |
|---|
| 2795 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2796 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id)) { |
|---|
| 3066 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || |
|---|
| 3067 | + !i40e_vc_isvalid_vsi_id(vf, vfl->vsi_id)) { |
|---|
| 2797 | 3068 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2798 | 3069 | goto error_param; |
|---|
| 2799 | 3070 | } |
|---|
| .. | .. |
|---|
| 2807 | 3078 | |
|---|
| 2808 | 3079 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 2809 | 3080 | if (vsi->info.pvid) { |
|---|
| 2810 | | - aq_ret = I40E_ERR_PARAM; |
|---|
| 3081 | + if (vfl->num_elements > 1 || vfl->vlan_id[0]) |
|---|
| 3082 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 2811 | 3083 | goto error_param; |
|---|
| 2812 | 3084 | } |
|---|
| 2813 | 3085 | |
|---|
| .. | .. |
|---|
| 2865 | 3137 | * i40e_vc_iwarp_qvmap_msg |
|---|
| 2866 | 3138 | * @vf: pointer to the VF info |
|---|
| 2867 | 3139 | * @msg: pointer to the msg buffer |
|---|
| 2868 | | - * @msglen: msg length |
|---|
| 2869 | 3140 | * @config: config qvmap or release it |
|---|
| 2870 | 3141 | * |
|---|
| 2871 | 3142 | * called from the VF for the iwarp msgs |
|---|
| 2872 | 3143 | **/ |
|---|
| 2873 | | -static int i40e_vc_iwarp_qvmap_msg(struct i40e_vf *vf, u8 *msg, u16 msglen, |
|---|
| 2874 | | - bool config) |
|---|
| 3144 | +static int i40e_vc_iwarp_qvmap_msg(struct i40e_vf *vf, u8 *msg, bool config) |
|---|
| 2875 | 3145 | { |
|---|
| 2876 | 3146 | struct virtchnl_iwarp_qvlist_info *qvlist_info = |
|---|
| 2877 | 3147 | (struct virtchnl_iwarp_qvlist_info *)msg; |
|---|
| .. | .. |
|---|
| 2902 | 3172 | * i40e_vc_config_rss_key |
|---|
| 2903 | 3173 | * @vf: pointer to the VF info |
|---|
| 2904 | 3174 | * @msg: pointer to the msg buffer |
|---|
| 2905 | | - * @msglen: msg length |
|---|
| 2906 | 3175 | * |
|---|
| 2907 | 3176 | * Configure the VF's RSS key |
|---|
| 2908 | 3177 | **/ |
|---|
| 2909 | | -static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 3178 | +static int i40e_vc_config_rss_key(struct i40e_vf *vf, u8 *msg) |
|---|
| 2910 | 3179 | { |
|---|
| 2911 | 3180 | struct virtchnl_rss_key *vrk = |
|---|
| 2912 | 3181 | (struct virtchnl_rss_key *)msg; |
|---|
| 2913 | 3182 | struct i40e_pf *pf = vf->pf; |
|---|
| 2914 | 3183 | struct i40e_vsi *vsi = NULL; |
|---|
| 2915 | | - u16 vsi_id = vrk->vsi_id; |
|---|
| 2916 | 3184 | i40e_status aq_ret = 0; |
|---|
| 2917 | 3185 | |
|---|
| 2918 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2919 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id) || |
|---|
| 2920 | | - (vrk->key_len != I40E_HKEY_ARRAY_SIZE)) { |
|---|
| 3186 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || |
|---|
| 3187 | + !i40e_vc_isvalid_vsi_id(vf, vrk->vsi_id) || |
|---|
| 3188 | + vrk->key_len != I40E_HKEY_ARRAY_SIZE) { |
|---|
| 2921 | 3189 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2922 | 3190 | goto err; |
|---|
| 2923 | 3191 | } |
|---|
| .. | .. |
|---|
| 2934 | 3202 | * i40e_vc_config_rss_lut |
|---|
| 2935 | 3203 | * @vf: pointer to the VF info |
|---|
| 2936 | 3204 | * @msg: pointer to the msg buffer |
|---|
| 2937 | | - * @msglen: msg length |
|---|
| 2938 | 3205 | * |
|---|
| 2939 | 3206 | * Configure the VF's RSS LUT |
|---|
| 2940 | 3207 | **/ |
|---|
| 2941 | | -static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 3208 | +static int i40e_vc_config_rss_lut(struct i40e_vf *vf, u8 *msg) |
|---|
| 2942 | 3209 | { |
|---|
| 2943 | 3210 | struct virtchnl_rss_lut *vrl = |
|---|
| 2944 | 3211 | (struct virtchnl_rss_lut *)msg; |
|---|
| 2945 | 3212 | struct i40e_pf *pf = vf->pf; |
|---|
| 2946 | 3213 | struct i40e_vsi *vsi = NULL; |
|---|
| 2947 | | - u16 vsi_id = vrl->vsi_id; |
|---|
| 2948 | 3214 | i40e_status aq_ret = 0; |
|---|
| 3215 | + u16 i; |
|---|
| 2949 | 3216 | |
|---|
| 2950 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) || |
|---|
| 2951 | | - !i40e_vc_isvalid_vsi_id(vf, vsi_id) || |
|---|
| 2952 | | - (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE)) { |
|---|
| 3217 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE) || |
|---|
| 3218 | + !i40e_vc_isvalid_vsi_id(vf, vrl->vsi_id) || |
|---|
| 3219 | + vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE) { |
|---|
| 2953 | 3220 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2954 | 3221 | goto err; |
|---|
| 2955 | 3222 | } |
|---|
| 3223 | + |
|---|
| 3224 | + for (i = 0; i < vrl->lut_entries; i++) |
|---|
| 3225 | + if (vrl->lut[i] >= vf->num_queue_pairs) { |
|---|
| 3226 | + aq_ret = I40E_ERR_PARAM; |
|---|
| 3227 | + goto err; |
|---|
| 3228 | + } |
|---|
| 2956 | 3229 | |
|---|
| 2957 | 3230 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 2958 | 3231 | aq_ret = i40e_config_rss(vsi, NULL, vrl->lut, I40E_VF_HLUT_ARRAY_SIZE); |
|---|
| .. | .. |
|---|
| 2966 | 3239 | * i40e_vc_get_rss_hena |
|---|
| 2967 | 3240 | * @vf: pointer to the VF info |
|---|
| 2968 | 3241 | * @msg: pointer to the msg buffer |
|---|
| 2969 | | - * @msglen: msg length |
|---|
| 2970 | 3242 | * |
|---|
| 2971 | 3243 | * Return the RSS HENA bits allowed by the hardware |
|---|
| 2972 | 3244 | **/ |
|---|
| 2973 | | -static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 3245 | +static int i40e_vc_get_rss_hena(struct i40e_vf *vf, u8 *msg) |
|---|
| 2974 | 3246 | { |
|---|
| 2975 | 3247 | struct virtchnl_rss_hena *vrh = NULL; |
|---|
| 2976 | 3248 | struct i40e_pf *pf = vf->pf; |
|---|
| 2977 | 3249 | i40e_status aq_ret = 0; |
|---|
| 2978 | 3250 | int len = 0; |
|---|
| 2979 | 3251 | |
|---|
| 2980 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3252 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 2981 | 3253 | aq_ret = I40E_ERR_PARAM; |
|---|
| 2982 | 3254 | goto err; |
|---|
| 2983 | 3255 | } |
|---|
| .. | .. |
|---|
| 3002 | 3274 | * i40e_vc_set_rss_hena |
|---|
| 3003 | 3275 | * @vf: pointer to the VF info |
|---|
| 3004 | 3276 | * @msg: pointer to the msg buffer |
|---|
| 3005 | | - * @msglen: msg length |
|---|
| 3006 | 3277 | * |
|---|
| 3007 | 3278 | * Set the RSS HENA bits for the VF |
|---|
| 3008 | 3279 | **/ |
|---|
| 3009 | | -static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg, u16 msglen) |
|---|
| 3280 | +static int i40e_vc_set_rss_hena(struct i40e_vf *vf, u8 *msg) |
|---|
| 3010 | 3281 | { |
|---|
| 3011 | 3282 | struct virtchnl_rss_hena *vrh = |
|---|
| 3012 | 3283 | (struct virtchnl_rss_hena *)msg; |
|---|
| .. | .. |
|---|
| 3014 | 3285 | struct i40e_hw *hw = &pf->hw; |
|---|
| 3015 | 3286 | i40e_status aq_ret = 0; |
|---|
| 3016 | 3287 | |
|---|
| 3017 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3288 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3018 | 3289 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3019 | 3290 | goto err; |
|---|
| 3020 | 3291 | } |
|---|
| .. | .. |
|---|
| 3031 | 3302 | * i40e_vc_enable_vlan_stripping |
|---|
| 3032 | 3303 | * @vf: pointer to the VF info |
|---|
| 3033 | 3304 | * @msg: pointer to the msg buffer |
|---|
| 3034 | | - * @msglen: msg length |
|---|
| 3035 | 3305 | * |
|---|
| 3036 | 3306 | * Enable vlan header stripping for the VF |
|---|
| 3037 | 3307 | **/ |
|---|
| 3038 | | -static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg, |
|---|
| 3039 | | - u16 msglen) |
|---|
| 3308 | +static int i40e_vc_enable_vlan_stripping(struct i40e_vf *vf, u8 *msg) |
|---|
| 3040 | 3309 | { |
|---|
| 3041 | | - struct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx]; |
|---|
| 3042 | 3310 | i40e_status aq_ret = 0; |
|---|
| 3311 | + struct i40e_vsi *vsi; |
|---|
| 3043 | 3312 | |
|---|
| 3044 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3313 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3045 | 3314 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3046 | 3315 | goto err; |
|---|
| 3047 | 3316 | } |
|---|
| 3048 | 3317 | |
|---|
| 3318 | + vsi = vf->pf->vsi[vf->lan_vsi_idx]; |
|---|
| 3049 | 3319 | i40e_vlan_stripping_enable(vsi); |
|---|
| 3050 | 3320 | |
|---|
| 3051 | 3321 | /* send the response to the VF */ |
|---|
| .. | .. |
|---|
| 3058 | 3328 | * i40e_vc_disable_vlan_stripping |
|---|
| 3059 | 3329 | * @vf: pointer to the VF info |
|---|
| 3060 | 3330 | * @msg: pointer to the msg buffer |
|---|
| 3061 | | - * @msglen: msg length |
|---|
| 3062 | 3331 | * |
|---|
| 3063 | 3332 | * Disable vlan header stripping for the VF |
|---|
| 3064 | 3333 | **/ |
|---|
| 3065 | | -static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg, |
|---|
| 3066 | | - u16 msglen) |
|---|
| 3334 | +static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg) |
|---|
| 3067 | 3335 | { |
|---|
| 3068 | | - struct i40e_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx]; |
|---|
| 3069 | 3336 | i40e_status aq_ret = 0; |
|---|
| 3337 | + struct i40e_vsi *vsi; |
|---|
| 3070 | 3338 | |
|---|
| 3071 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3339 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3072 | 3340 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3073 | 3341 | goto err; |
|---|
| 3074 | 3342 | } |
|---|
| 3075 | 3343 | |
|---|
| 3344 | + vsi = vf->pf->vsi[vf->lan_vsi_idx]; |
|---|
| 3076 | 3345 | i40e_vlan_stripping_disable(vsi); |
|---|
| 3077 | 3346 | |
|---|
| 3078 | 3347 | /* send the response to the VF */ |
|---|
| .. | .. |
|---|
| 3083 | 3352 | |
|---|
| 3084 | 3353 | /** |
|---|
| 3085 | 3354 | * i40e_validate_cloud_filter |
|---|
| 3086 | | - * @mask: mask for TC filter |
|---|
| 3087 | | - * @data: data for TC filter |
|---|
| 3355 | + * @vf: pointer to VF structure |
|---|
| 3356 | + * @tc_filter: pointer to filter requested |
|---|
| 3088 | 3357 | * |
|---|
| 3089 | 3358 | * This function validates cloud filter programmed as TC filter for ADq |
|---|
| 3090 | 3359 | **/ |
|---|
| .. | .. |
|---|
| 3179 | 3448 | } |
|---|
| 3180 | 3449 | |
|---|
| 3181 | 3450 | if (mask.dst_port & data.dst_port) { |
|---|
| 3182 | | - if (!data.dst_port || be16_to_cpu(data.dst_port) > 0xFFFF) { |
|---|
| 3451 | + if (!data.dst_port) { |
|---|
| 3183 | 3452 | dev_info(&pf->pdev->dev, "VF %d: Invalid Dest port\n", |
|---|
| 3184 | 3453 | vf->vf_id); |
|---|
| 3185 | 3454 | goto err; |
|---|
| .. | .. |
|---|
| 3187 | 3456 | } |
|---|
| 3188 | 3457 | |
|---|
| 3189 | 3458 | if (mask.src_port & data.src_port) { |
|---|
| 3190 | | - if (!data.src_port || be16_to_cpu(data.src_port) > 0xFFFF) { |
|---|
| 3459 | + if (!data.src_port) { |
|---|
| 3191 | 3460 | dev_info(&pf->pdev->dev, "VF %d: Invalid Source port\n", |
|---|
| 3192 | 3461 | vf->vf_id); |
|---|
| 3193 | 3462 | goto err; |
|---|
| .. | .. |
|---|
| 3217 | 3486 | /** |
|---|
| 3218 | 3487 | * i40e_find_vsi_from_seid - searches for the vsi with the given seid |
|---|
| 3219 | 3488 | * @vf: pointer to the VF info |
|---|
| 3220 | | - * @seid - seid of the vsi it is searching for |
|---|
| 3489 | + * @seid: seid of the vsi it is searching for |
|---|
| 3221 | 3490 | **/ |
|---|
| 3222 | 3491 | static struct i40e_vsi *i40e_find_vsi_from_seid(struct i40e_vf *vf, u16 seid) |
|---|
| 3223 | 3492 | { |
|---|
| .. | .. |
|---|
| 3294 | 3563 | i40e_status aq_ret = 0; |
|---|
| 3295 | 3564 | int i, ret; |
|---|
| 3296 | 3565 | |
|---|
| 3297 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3566 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3298 | 3567 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3299 | 3568 | goto err; |
|---|
| 3300 | 3569 | } |
|---|
| .. | .. |
|---|
| 3425 | 3694 | i40e_status aq_ret = 0; |
|---|
| 3426 | 3695 | int i, ret; |
|---|
| 3427 | 3696 | |
|---|
| 3428 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3697 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3429 | 3698 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3430 | 3699 | goto err_out; |
|---|
| 3431 | 3700 | } |
|---|
| .. | .. |
|---|
| 3530 | 3799 | (struct virtchnl_tc_info *)msg; |
|---|
| 3531 | 3800 | struct i40e_pf *pf = vf->pf; |
|---|
| 3532 | 3801 | struct i40e_link_status *ls = &pf->hw.phy.link_info; |
|---|
| 3533 | | - int i, adq_request_qps = 0, speed = 0; |
|---|
| 3802 | + int i, adq_request_qps = 0; |
|---|
| 3534 | 3803 | i40e_status aq_ret = 0; |
|---|
| 3804 | + u64 speed = 0; |
|---|
| 3535 | 3805 | |
|---|
| 3536 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3806 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3537 | 3807 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3538 | 3808 | goto err; |
|---|
| 3539 | 3809 | } |
|---|
| .. | .. |
|---|
| 3557 | 3827 | /* max number of traffic classes for VF currently capped at 4 */ |
|---|
| 3558 | 3828 | if (!tci->num_tc || tci->num_tc > I40E_MAX_VF_VSI) { |
|---|
| 3559 | 3829 | dev_err(&pf->pdev->dev, |
|---|
| 3560 | | - "VF %d trying to set %u TCs, valid range 1-4 TCs per VF\n", |
|---|
| 3561 | | - vf->vf_id, tci->num_tc); |
|---|
| 3830 | + "VF %d trying to set %u TCs, valid range 1-%u TCs per VF\n", |
|---|
| 3831 | + vf->vf_id, tci->num_tc, I40E_MAX_VF_VSI); |
|---|
| 3562 | 3832 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3563 | 3833 | goto err; |
|---|
| 3564 | 3834 | } |
|---|
| .. | .. |
|---|
| 3568 | 3838 | if (!tci->list[i].count || |
|---|
| 3569 | 3839 | tci->list[i].count > I40E_DEFAULT_QUEUES_PER_VF) { |
|---|
| 3570 | 3840 | dev_err(&pf->pdev->dev, |
|---|
| 3571 | | - "VF %d: TC %d trying to set %u queues, valid range 1-4 queues per TC\n", |
|---|
| 3572 | | - vf->vf_id, i, tci->list[i].count); |
|---|
| 3841 | + "VF %d: TC %d trying to set %u queues, valid range 1-%u queues per TC\n", |
|---|
| 3842 | + vf->vf_id, i, tci->list[i].count, |
|---|
| 3843 | + I40E_DEFAULT_QUEUES_PER_VF); |
|---|
| 3573 | 3844 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3574 | 3845 | goto err; |
|---|
| 3575 | 3846 | } |
|---|
| .. | .. |
|---|
| 3641 | 3912 | vf->adq_enabled = true; |
|---|
| 3642 | 3913 | |
|---|
| 3643 | 3914 | /* reset the VF in order to allocate resources */ |
|---|
| 3644 | | - i40e_vc_notify_vf_reset(vf); |
|---|
| 3645 | | - i40e_reset_vf(vf, false); |
|---|
| 3915 | + i40e_vc_reset_vf(vf, true); |
|---|
| 3646 | 3916 | |
|---|
| 3647 | 3917 | return I40E_SUCCESS; |
|---|
| 3648 | 3918 | |
|---|
| .. | .. |
|---|
| 3662 | 3932 | struct i40e_pf *pf = vf->pf; |
|---|
| 3663 | 3933 | i40e_status aq_ret = 0; |
|---|
| 3664 | 3934 | |
|---|
| 3665 | | - if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { |
|---|
| 3935 | + if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { |
|---|
| 3666 | 3936 | aq_ret = I40E_ERR_PARAM; |
|---|
| 3667 | 3937 | goto err; |
|---|
| 3668 | 3938 | } |
|---|
| .. | .. |
|---|
| 3682 | 3952 | } |
|---|
| 3683 | 3953 | |
|---|
| 3684 | 3954 | /* reset the VF in order to allocate resources */ |
|---|
| 3685 | | - i40e_vc_notify_vf_reset(vf); |
|---|
| 3686 | | - i40e_reset_vf(vf, false); |
|---|
| 3955 | + i40e_vc_reset_vf(vf, true); |
|---|
| 3687 | 3956 | |
|---|
| 3688 | 3957 | return I40E_SUCCESS; |
|---|
| 3689 | 3958 | |
|---|
| .. | .. |
|---|
| 3713 | 3982 | int ret; |
|---|
| 3714 | 3983 | |
|---|
| 3715 | 3984 | pf->vf_aq_requests++; |
|---|
| 3716 | | - if (local_vf_id >= pf->num_alloc_vfs) |
|---|
| 3985 | + if (local_vf_id < 0 || local_vf_id >= pf->num_alloc_vfs) |
|---|
| 3717 | 3986 | return -EINVAL; |
|---|
| 3718 | 3987 | vf = &(pf->vf[local_vf_id]); |
|---|
| 3719 | 3988 | |
|---|
| .. | .. |
|---|
| 3724 | 3993 | /* perform basic checks on the msg */ |
|---|
| 3725 | 3994 | ret = virtchnl_vc_validate_vf_msg(&vf->vf_ver, v_opcode, msg, msglen); |
|---|
| 3726 | 3995 | |
|---|
| 3727 | | - /* perform additional checks specific to this driver */ |
|---|
| 3728 | | - if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_KEY) { |
|---|
| 3729 | | - struct virtchnl_rss_key *vrk = (struct virtchnl_rss_key *)msg; |
|---|
| 3730 | | - |
|---|
| 3731 | | - if (vrk->key_len != I40E_HKEY_ARRAY_SIZE) |
|---|
| 3732 | | - ret = -EINVAL; |
|---|
| 3733 | | - } else if (v_opcode == VIRTCHNL_OP_CONFIG_RSS_LUT) { |
|---|
| 3734 | | - struct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg; |
|---|
| 3735 | | - |
|---|
| 3736 | | - if (vrl->lut_entries != I40E_VF_HLUT_ARRAY_SIZE) |
|---|
| 3737 | | - ret = -EINVAL; |
|---|
| 3738 | | - } |
|---|
| 3739 | | - |
|---|
| 3740 | 3996 | if (ret) { |
|---|
| 3741 | 3997 | i40e_vc_send_resp_to_vf(vf, v_opcode, I40E_ERR_PARAM); |
|---|
| 3742 | 3998 | dev_err(&pf->pdev->dev, "Invalid message from VF %d, opcode %d, len %d\n", |
|---|
| 3743 | 3999 | local_vf_id, v_opcode, msglen); |
|---|
| 3744 | 4000 | switch (ret) { |
|---|
| 3745 | | - case VIRTCHNL_ERR_PARAM: |
|---|
| 4001 | + case VIRTCHNL_STATUS_ERR_PARAM: |
|---|
| 3746 | 4002 | return -EPERM; |
|---|
| 3747 | 4003 | default: |
|---|
| 3748 | 4004 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 3758 | 4014 | i40e_vc_notify_vf_link_state(vf); |
|---|
| 3759 | 4015 | break; |
|---|
| 3760 | 4016 | case VIRTCHNL_OP_RESET_VF: |
|---|
| 3761 | | - i40e_vc_reset_vf_msg(vf); |
|---|
| 4017 | + i40e_vc_reset_vf(vf, false); |
|---|
| 3762 | 4018 | ret = 0; |
|---|
| 3763 | 4019 | break; |
|---|
| 3764 | 4020 | case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: |
|---|
| 3765 | | - ret = i40e_vc_config_promiscuous_mode_msg(vf, msg, msglen); |
|---|
| 4021 | + ret = i40e_vc_config_promiscuous_mode_msg(vf, msg); |
|---|
| 3766 | 4022 | break; |
|---|
| 3767 | 4023 | case VIRTCHNL_OP_CONFIG_VSI_QUEUES: |
|---|
| 3768 | | - ret = i40e_vc_config_queues_msg(vf, msg, msglen); |
|---|
| 4024 | + ret = i40e_vc_config_queues_msg(vf, msg); |
|---|
| 3769 | 4025 | break; |
|---|
| 3770 | 4026 | case VIRTCHNL_OP_CONFIG_IRQ_MAP: |
|---|
| 3771 | | - ret = i40e_vc_config_irq_map_msg(vf, msg, msglen); |
|---|
| 4027 | + ret = i40e_vc_config_irq_map_msg(vf, msg); |
|---|
| 3772 | 4028 | break; |
|---|
| 3773 | 4029 | case VIRTCHNL_OP_ENABLE_QUEUES: |
|---|
| 3774 | | - ret = i40e_vc_enable_queues_msg(vf, msg, msglen); |
|---|
| 4030 | + ret = i40e_vc_enable_queues_msg(vf, msg); |
|---|
| 3775 | 4031 | i40e_vc_notify_vf_link_state(vf); |
|---|
| 3776 | 4032 | break; |
|---|
| 3777 | 4033 | case VIRTCHNL_OP_DISABLE_QUEUES: |
|---|
| 3778 | | - ret = i40e_vc_disable_queues_msg(vf, msg, msglen); |
|---|
| 4034 | + ret = i40e_vc_disable_queues_msg(vf, msg); |
|---|
| 3779 | 4035 | break; |
|---|
| 3780 | 4036 | case VIRTCHNL_OP_ADD_ETH_ADDR: |
|---|
| 3781 | | - ret = i40e_vc_add_mac_addr_msg(vf, msg, msglen); |
|---|
| 4037 | + ret = i40e_vc_add_mac_addr_msg(vf, msg); |
|---|
| 3782 | 4038 | break; |
|---|
| 3783 | 4039 | case VIRTCHNL_OP_DEL_ETH_ADDR: |
|---|
| 3784 | | - ret = i40e_vc_del_mac_addr_msg(vf, msg, msglen); |
|---|
| 4040 | + ret = i40e_vc_del_mac_addr_msg(vf, msg); |
|---|
| 3785 | 4041 | break; |
|---|
| 3786 | 4042 | case VIRTCHNL_OP_ADD_VLAN: |
|---|
| 3787 | | - ret = i40e_vc_add_vlan_msg(vf, msg, msglen); |
|---|
| 4043 | + ret = i40e_vc_add_vlan_msg(vf, msg); |
|---|
| 3788 | 4044 | break; |
|---|
| 3789 | 4045 | case VIRTCHNL_OP_DEL_VLAN: |
|---|
| 3790 | | - ret = i40e_vc_remove_vlan_msg(vf, msg, msglen); |
|---|
| 4046 | + ret = i40e_vc_remove_vlan_msg(vf, msg); |
|---|
| 3791 | 4047 | break; |
|---|
| 3792 | 4048 | case VIRTCHNL_OP_GET_STATS: |
|---|
| 3793 | | - ret = i40e_vc_get_stats_msg(vf, msg, msglen); |
|---|
| 4049 | + ret = i40e_vc_get_stats_msg(vf, msg); |
|---|
| 3794 | 4050 | break; |
|---|
| 3795 | 4051 | case VIRTCHNL_OP_IWARP: |
|---|
| 3796 | 4052 | ret = i40e_vc_iwarp_msg(vf, msg, msglen); |
|---|
| 3797 | 4053 | break; |
|---|
| 3798 | 4054 | case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP: |
|---|
| 3799 | | - ret = i40e_vc_iwarp_qvmap_msg(vf, msg, msglen, true); |
|---|
| 4055 | + ret = i40e_vc_iwarp_qvmap_msg(vf, msg, true); |
|---|
| 3800 | 4056 | break; |
|---|
| 3801 | 4057 | case VIRTCHNL_OP_RELEASE_IWARP_IRQ_MAP: |
|---|
| 3802 | | - ret = i40e_vc_iwarp_qvmap_msg(vf, msg, msglen, false); |
|---|
| 4058 | + ret = i40e_vc_iwarp_qvmap_msg(vf, msg, false); |
|---|
| 3803 | 4059 | break; |
|---|
| 3804 | 4060 | case VIRTCHNL_OP_CONFIG_RSS_KEY: |
|---|
| 3805 | | - ret = i40e_vc_config_rss_key(vf, msg, msglen); |
|---|
| 4061 | + ret = i40e_vc_config_rss_key(vf, msg); |
|---|
| 3806 | 4062 | break; |
|---|
| 3807 | 4063 | case VIRTCHNL_OP_CONFIG_RSS_LUT: |
|---|
| 3808 | | - ret = i40e_vc_config_rss_lut(vf, msg, msglen); |
|---|
| 4064 | + ret = i40e_vc_config_rss_lut(vf, msg); |
|---|
| 3809 | 4065 | break; |
|---|
| 3810 | 4066 | case VIRTCHNL_OP_GET_RSS_HENA_CAPS: |
|---|
| 3811 | | - ret = i40e_vc_get_rss_hena(vf, msg, msglen); |
|---|
| 4067 | + ret = i40e_vc_get_rss_hena(vf, msg); |
|---|
| 3812 | 4068 | break; |
|---|
| 3813 | 4069 | case VIRTCHNL_OP_SET_RSS_HENA: |
|---|
| 3814 | | - ret = i40e_vc_set_rss_hena(vf, msg, msglen); |
|---|
| 4070 | + ret = i40e_vc_set_rss_hena(vf, msg); |
|---|
| 3815 | 4071 | break; |
|---|
| 3816 | 4072 | case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING: |
|---|
| 3817 | | - ret = i40e_vc_enable_vlan_stripping(vf, msg, msglen); |
|---|
| 4073 | + ret = i40e_vc_enable_vlan_stripping(vf, msg); |
|---|
| 3818 | 4074 | break; |
|---|
| 3819 | 4075 | case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING: |
|---|
| 3820 | | - ret = i40e_vc_disable_vlan_stripping(vf, msg, msglen); |
|---|
| 4076 | + ret = i40e_vc_disable_vlan_stripping(vf, msg); |
|---|
| 3821 | 4077 | break; |
|---|
| 3822 | 4078 | case VIRTCHNL_OP_REQUEST_QUEUES: |
|---|
| 3823 | | - ret = i40e_vc_request_queues_msg(vf, msg, msglen); |
|---|
| 4079 | + ret = i40e_vc_request_queues_msg(vf, msg); |
|---|
| 3824 | 4080 | break; |
|---|
| 3825 | 4081 | case VIRTCHNL_OP_ENABLE_CHANNELS: |
|---|
| 3826 | 4082 | ret = i40e_vc_add_qch_msg(vf, msg); |
|---|
| .. | .. |
|---|
| 3889 | 4145 | } |
|---|
| 3890 | 4146 | |
|---|
| 3891 | 4147 | /** |
|---|
| 4148 | + * i40e_validate_vf |
|---|
| 4149 | + * @pf: the physical function |
|---|
| 4150 | + * @vf_id: VF identifier |
|---|
| 4151 | + * |
|---|
| 4152 | + * Check that the VF is enabled and the VSI exists. |
|---|
| 4153 | + * |
|---|
| 4154 | + * Returns 0 on success, negative on failure |
|---|
| 4155 | + **/ |
|---|
| 4156 | +static int i40e_validate_vf(struct i40e_pf *pf, int vf_id) |
|---|
| 4157 | +{ |
|---|
| 4158 | + struct i40e_vsi *vsi; |
|---|
| 4159 | + struct i40e_vf *vf; |
|---|
| 4160 | + int ret = 0; |
|---|
| 4161 | + |
|---|
| 4162 | + if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 4163 | + dev_err(&pf->pdev->dev, |
|---|
| 4164 | + "Invalid VF Identifier %d\n", vf_id); |
|---|
| 4165 | + ret = -EINVAL; |
|---|
| 4166 | + goto err_out; |
|---|
| 4167 | + } |
|---|
| 4168 | + vf = &pf->vf[vf_id]; |
|---|
| 4169 | + vsi = i40e_find_vsi_from_id(pf, vf->lan_vsi_id); |
|---|
| 4170 | + if (!vsi) |
|---|
| 4171 | + ret = -EINVAL; |
|---|
| 4172 | +err_out: |
|---|
| 4173 | + return ret; |
|---|
| 4174 | +} |
|---|
| 4175 | + |
|---|
| 4176 | +/** |
|---|
| 3892 | 4177 | * i40e_ndo_set_vf_mac |
|---|
| 3893 | 4178 | * @netdev: network interface device structure |
|---|
| 3894 | 4179 | * @vf_id: VF identifier |
|---|
| .. | .. |
|---|
| 3908 | 4193 | int bkt; |
|---|
| 3909 | 4194 | u8 i; |
|---|
| 3910 | 4195 | |
|---|
| 3911 | | - /* validate the request */ |
|---|
| 3912 | | - if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 3913 | | - dev_err(&pf->pdev->dev, |
|---|
| 3914 | | - "Invalid VF Identifier %d\n", vf_id); |
|---|
| 3915 | | - ret = -EINVAL; |
|---|
| 3916 | | - goto error_param; |
|---|
| 4196 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4197 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4198 | + return -EAGAIN; |
|---|
| 3917 | 4199 | } |
|---|
| 3918 | 4200 | |
|---|
| 3919 | | - vf = &(pf->vf[vf_id]); |
|---|
| 3920 | | - vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4201 | + /* validate the request */ |
|---|
| 4202 | + ret = i40e_validate_vf(pf, vf_id); |
|---|
| 4203 | + if (ret) |
|---|
| 4204 | + goto error_param; |
|---|
| 4205 | + |
|---|
| 4206 | + vf = &pf->vf[vf_id]; |
|---|
| 3921 | 4207 | |
|---|
| 3922 | 4208 | /* When the VF is resetting wait until it is done. |
|---|
| 3923 | 4209 | * It can take up to 200 milliseconds, |
|---|
| 3924 | 4210 | * but wait for up to 300 milliseconds to be safe. |
|---|
| 4211 | + * Acquire the VSI pointer only after the VF has been |
|---|
| 4212 | + * properly initialized. |
|---|
| 3925 | 4213 | */ |
|---|
| 3926 | 4214 | for (i = 0; i < 15; i++) { |
|---|
| 3927 | 4215 | if (test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) |
|---|
| .. | .. |
|---|
| 3934 | 4222 | ret = -EAGAIN; |
|---|
| 3935 | 4223 | goto error_param; |
|---|
| 3936 | 4224 | } |
|---|
| 4225 | + vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 3937 | 4226 | |
|---|
| 3938 | 4227 | if (is_multicast_ether_addr(mac)) { |
|---|
| 3939 | 4228 | dev_err(&pf->pdev->dev, |
|---|
| .. | .. |
|---|
| 3976 | 4265 | mac, vf_id); |
|---|
| 3977 | 4266 | } |
|---|
| 3978 | 4267 | |
|---|
| 3979 | | - /* Force the VF driver stop so it has to reload with new MAC address */ |
|---|
| 3980 | | - i40e_vc_disable_vf(vf); |
|---|
| 3981 | | - dev_info(&pf->pdev->dev, "Reload the VF driver to make this change effective.\n"); |
|---|
| 4268 | + /* Force the VF interface down so it has to bring up with new MAC |
|---|
| 4269 | + * address |
|---|
| 4270 | + */ |
|---|
| 4271 | + i40e_vc_reset_vf(vf, true); |
|---|
| 4272 | + dev_info(&pf->pdev->dev, "Bring down and up the VF interface to make this change effective.\n"); |
|---|
| 3982 | 4273 | |
|---|
| 3983 | 4274 | error_param: |
|---|
| 4275 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 3984 | 4276 | return ret; |
|---|
| 3985 | 4277 | } |
|---|
| 3986 | 4278 | |
|---|
| .. | .. |
|---|
| 3999 | 4291 | { |
|---|
| 4000 | 4292 | u16 vlanprio = vlan_id | (qos << I40E_VLAN_PRIORITY_SHIFT); |
|---|
| 4001 | 4293 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
|---|
| 4294 | + bool allmulti = false, alluni = false; |
|---|
| 4002 | 4295 | struct i40e_pf *pf = np->vsi->back; |
|---|
| 4003 | 4296 | struct i40e_vsi *vsi; |
|---|
| 4004 | 4297 | struct i40e_vf *vf; |
|---|
| 4005 | 4298 | int ret = 0; |
|---|
| 4006 | 4299 | |
|---|
| 4007 | | - /* validate the request */ |
|---|
| 4008 | | - if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 4009 | | - dev_err(&pf->pdev->dev, "Invalid VF Identifier %d\n", vf_id); |
|---|
| 4010 | | - ret = -EINVAL; |
|---|
| 4011 | | - goto error_pvid; |
|---|
| 4300 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4301 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4302 | + return -EAGAIN; |
|---|
| 4012 | 4303 | } |
|---|
| 4304 | + |
|---|
| 4305 | + /* validate the request */ |
|---|
| 4306 | + ret = i40e_validate_vf(pf, vf_id); |
|---|
| 4307 | + if (ret) |
|---|
| 4308 | + goto error_pvid; |
|---|
| 4013 | 4309 | |
|---|
| 4014 | 4310 | if ((vlan_id > I40E_MAX_VLANID) || (qos > 7)) { |
|---|
| 4015 | 4311 | dev_err(&pf->pdev->dev, "Invalid VF Parameters\n"); |
|---|
| .. | .. |
|---|
| 4023 | 4319 | goto error_pvid; |
|---|
| 4024 | 4320 | } |
|---|
| 4025 | 4321 | |
|---|
| 4026 | | - vf = &(pf->vf[vf_id]); |
|---|
| 4322 | + vf = &pf->vf[vf_id]; |
|---|
| 4027 | 4323 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4028 | 4324 | if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { |
|---|
| 4029 | 4325 | dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n", |
|---|
| .. | .. |
|---|
| 4036 | 4332 | /* duplicate request, so just return success */ |
|---|
| 4037 | 4333 | goto error_pvid; |
|---|
| 4038 | 4334 | |
|---|
| 4039 | | - i40e_vc_disable_vf(vf); |
|---|
| 4335 | + i40e_vc_reset_vf(vf, true); |
|---|
| 4040 | 4336 | /* During reset the VF got a new VSI, so refresh a pointer. */ |
|---|
| 4041 | 4337 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4042 | 4338 | /* Locked once because multiple functions below iterate list */ |
|---|
| .. | .. |
|---|
| 4070 | 4366 | } |
|---|
| 4071 | 4367 | |
|---|
| 4072 | 4368 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 4369 | + |
|---|
| 4370 | + /* disable promisc modes in case they were enabled */ |
|---|
| 4371 | + ret = i40e_config_vf_promiscuous_mode(vf, vf->lan_vsi_id, |
|---|
| 4372 | + allmulti, alluni); |
|---|
| 4373 | + if (ret) { |
|---|
| 4374 | + dev_err(&pf->pdev->dev, "Unable to config VF promiscuous mode\n"); |
|---|
| 4375 | + goto error_pvid; |
|---|
| 4376 | + } |
|---|
| 4377 | + |
|---|
| 4073 | 4378 | if (vlan_id || qos) |
|---|
| 4074 | 4379 | ret = i40e_vsi_add_pvid(vsi, vlanprio); |
|---|
| 4075 | 4380 | else |
|---|
| .. | .. |
|---|
| 4096 | 4401 | |
|---|
| 4097 | 4402 | spin_unlock_bh(&vsi->mac_filter_hash_lock); |
|---|
| 4098 | 4403 | |
|---|
| 4404 | + if (test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states)) |
|---|
| 4405 | + alluni = true; |
|---|
| 4406 | + |
|---|
| 4407 | + if (test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states)) |
|---|
| 4408 | + allmulti = true; |
|---|
| 4409 | + |
|---|
| 4099 | 4410 | /* Schedule the worker thread to take care of applying changes */ |
|---|
| 4100 | 4411 | i40e_service_event_schedule(vsi->back); |
|---|
| 4101 | 4412 | |
|---|
| .. | .. |
|---|
| 4108 | 4419 | * default LAN MAC address. |
|---|
| 4109 | 4420 | */ |
|---|
| 4110 | 4421 | vf->port_vlan_id = le16_to_cpu(vsi->info.pvid); |
|---|
| 4422 | + |
|---|
| 4423 | + ret = i40e_config_vf_promiscuous_mode(vf, vsi->id, allmulti, alluni); |
|---|
| 4424 | + if (ret) { |
|---|
| 4425 | + dev_err(&pf->pdev->dev, "Unable to config vf promiscuous mode\n"); |
|---|
| 4426 | + goto error_pvid; |
|---|
| 4427 | + } |
|---|
| 4428 | + |
|---|
| 4111 | 4429 | ret = 0; |
|---|
| 4112 | 4430 | |
|---|
| 4113 | 4431 | error_pvid: |
|---|
| 4432 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4114 | 4433 | return ret; |
|---|
| 4115 | 4434 | } |
|---|
| 4116 | 4435 | |
|---|
| .. | .. |
|---|
| 4132 | 4451 | struct i40e_vf *vf; |
|---|
| 4133 | 4452 | int ret = 0; |
|---|
| 4134 | 4453 | |
|---|
| 4135 | | - /* validate the request */ |
|---|
| 4136 | | - if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 4137 | | - dev_err(&pf->pdev->dev, "Invalid VF Identifier %d.\n", vf_id); |
|---|
| 4138 | | - ret = -EINVAL; |
|---|
| 4139 | | - goto error; |
|---|
| 4454 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4455 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4456 | + return -EAGAIN; |
|---|
| 4140 | 4457 | } |
|---|
| 4458 | + |
|---|
| 4459 | + /* validate the request */ |
|---|
| 4460 | + ret = i40e_validate_vf(pf, vf_id); |
|---|
| 4461 | + if (ret) |
|---|
| 4462 | + goto error; |
|---|
| 4141 | 4463 | |
|---|
| 4142 | 4464 | if (min_tx_rate) { |
|---|
| 4143 | 4465 | dev_err(&pf->pdev->dev, "Invalid min tx rate (%d) (greater than 0) specified for VF %d.\n", |
|---|
| 4144 | 4466 | min_tx_rate, vf_id); |
|---|
| 4145 | | - return -EINVAL; |
|---|
| 4467 | + ret = -EINVAL; |
|---|
| 4468 | + goto error; |
|---|
| 4146 | 4469 | } |
|---|
| 4147 | 4470 | |
|---|
| 4148 | | - vf = &(pf->vf[vf_id]); |
|---|
| 4471 | + vf = &pf->vf[vf_id]; |
|---|
| 4149 | 4472 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4150 | 4473 | if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { |
|---|
| 4151 | 4474 | dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n", |
|---|
| .. | .. |
|---|
| 4160 | 4483 | |
|---|
| 4161 | 4484 | vf->tx_rate = max_tx_rate; |
|---|
| 4162 | 4485 | error: |
|---|
| 4486 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4163 | 4487 | return ret; |
|---|
| 4164 | 4488 | } |
|---|
| 4165 | 4489 | |
|---|
| .. | .. |
|---|
| 4180 | 4504 | struct i40e_vf *vf; |
|---|
| 4181 | 4505 | int ret = 0; |
|---|
| 4182 | 4506 | |
|---|
| 4183 | | - /* validate the request */ |
|---|
| 4184 | | - if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 4185 | | - dev_err(&pf->pdev->dev, "Invalid VF Identifier %d\n", vf_id); |
|---|
| 4186 | | - ret = -EINVAL; |
|---|
| 4187 | | - goto error_param; |
|---|
| 4507 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4508 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4509 | + return -EAGAIN; |
|---|
| 4188 | 4510 | } |
|---|
| 4189 | 4511 | |
|---|
| 4190 | | - vf = &(pf->vf[vf_id]); |
|---|
| 4512 | + /* validate the request */ |
|---|
| 4513 | + ret = i40e_validate_vf(pf, vf_id); |
|---|
| 4514 | + if (ret) |
|---|
| 4515 | + goto error_param; |
|---|
| 4516 | + |
|---|
| 4517 | + vf = &pf->vf[vf_id]; |
|---|
| 4191 | 4518 | /* first vsi is always the LAN vsi */ |
|---|
| 4192 | 4519 | vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4193 | | - if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { |
|---|
| 4194 | | - dev_err(&pf->pdev->dev, "VF %d still in reset. Try again.\n", |
|---|
| 4195 | | - vf_id); |
|---|
| 4196 | | - ret = -EAGAIN; |
|---|
| 4520 | + if (!vsi) { |
|---|
| 4521 | + ret = -ENOENT; |
|---|
| 4197 | 4522 | goto error_param; |
|---|
| 4198 | 4523 | } |
|---|
| 4199 | 4524 | |
|---|
| .. | .. |
|---|
| 4217 | 4542 | ret = 0; |
|---|
| 4218 | 4543 | |
|---|
| 4219 | 4544 | error_param: |
|---|
| 4545 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4220 | 4546 | return ret; |
|---|
| 4221 | 4547 | } |
|---|
| 4222 | 4548 | |
|---|
| .. | .. |
|---|
| 4237 | 4563 | struct i40e_vf *vf; |
|---|
| 4238 | 4564 | int abs_vf_id; |
|---|
| 4239 | 4565 | int ret = 0; |
|---|
| 4566 | + |
|---|
| 4567 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4568 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4569 | + return -EAGAIN; |
|---|
| 4570 | + } |
|---|
| 4240 | 4571 | |
|---|
| 4241 | 4572 | /* validate the request */ |
|---|
| 4242 | 4573 | if (vf_id >= pf->num_alloc_vfs) { |
|---|
| .. | .. |
|---|
| 4281 | 4612 | 0, (u8 *)&pfe, sizeof(pfe), NULL); |
|---|
| 4282 | 4613 | |
|---|
| 4283 | 4614 | error_out: |
|---|
| 4615 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4284 | 4616 | return ret; |
|---|
| 4285 | 4617 | } |
|---|
| 4286 | 4618 | |
|---|
| .. | .. |
|---|
| 4301 | 4633 | struct i40e_hw *hw = &pf->hw; |
|---|
| 4302 | 4634 | struct i40e_vf *vf; |
|---|
| 4303 | 4635 | int ret = 0; |
|---|
| 4636 | + |
|---|
| 4637 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4638 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4639 | + return -EAGAIN; |
|---|
| 4640 | + } |
|---|
| 4304 | 4641 | |
|---|
| 4305 | 4642 | /* validate the request */ |
|---|
| 4306 | 4643 | if (vf_id >= pf->num_alloc_vfs) { |
|---|
| .. | .. |
|---|
| 4335 | 4672 | ret = -EIO; |
|---|
| 4336 | 4673 | } |
|---|
| 4337 | 4674 | out: |
|---|
| 4675 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4338 | 4676 | return ret; |
|---|
| 4339 | 4677 | } |
|---|
| 4340 | 4678 | |
|---|
| .. | .. |
|---|
| 4353 | 4691 | struct i40e_vf *vf; |
|---|
| 4354 | 4692 | int ret = 0; |
|---|
| 4355 | 4693 | |
|---|
| 4694 | + if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) { |
|---|
| 4695 | + dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n"); |
|---|
| 4696 | + return -EAGAIN; |
|---|
| 4697 | + } |
|---|
| 4698 | + |
|---|
| 4356 | 4699 | /* validate the request */ |
|---|
| 4357 | 4700 | if (vf_id >= pf->num_alloc_vfs) { |
|---|
| 4358 | 4701 | dev_err(&pf->pdev->dev, "Invalid VF Identifier %d\n", vf_id); |
|---|
| 4359 | | - return -EINVAL; |
|---|
| 4702 | + ret = -EINVAL; |
|---|
| 4703 | + goto out; |
|---|
| 4360 | 4704 | } |
|---|
| 4361 | 4705 | |
|---|
| 4362 | 4706 | if (pf->flags & I40E_FLAG_MFP_ENABLED) { |
|---|
| 4363 | 4707 | dev_err(&pf->pdev->dev, "Trusted VF not supported in MFP mode.\n"); |
|---|
| 4364 | | - return -EINVAL; |
|---|
| 4708 | + ret = -EINVAL; |
|---|
| 4709 | + goto out; |
|---|
| 4365 | 4710 | } |
|---|
| 4366 | 4711 | |
|---|
| 4367 | 4712 | vf = &pf->vf[vf_id]; |
|---|
| .. | .. |
|---|
| 4370 | 4715 | goto out; |
|---|
| 4371 | 4716 | |
|---|
| 4372 | 4717 | vf->trusted = setting; |
|---|
| 4373 | | - i40e_vc_disable_vf(vf); |
|---|
| 4718 | + i40e_vc_reset_vf(vf, true); |
|---|
| 4374 | 4719 | dev_info(&pf->pdev->dev, "VF %u is now %strusted\n", |
|---|
| 4375 | 4720 | vf_id, setting ? "" : "un"); |
|---|
| 4376 | 4721 | |
|---|
| .. | .. |
|---|
| 4384 | 4729 | } |
|---|
| 4385 | 4730 | |
|---|
| 4386 | 4731 | out: |
|---|
| 4732 | + clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); |
|---|
| 4387 | 4733 | return ret; |
|---|
| 4388 | 4734 | } |
|---|
| 4735 | + |
|---|
| 4736 | +/** |
|---|
| 4737 | + * i40e_get_vf_stats - populate some stats for the VF |
|---|
| 4738 | + * @netdev: the netdev of the PF |
|---|
| 4739 | + * @vf_id: the host OS identifier (0-127) |
|---|
| 4740 | + * @vf_stats: pointer to the OS memory to be initialized |
|---|
| 4741 | + */ |
|---|
| 4742 | +int i40e_get_vf_stats(struct net_device *netdev, int vf_id, |
|---|
| 4743 | + struct ifla_vf_stats *vf_stats) |
|---|
| 4744 | +{ |
|---|
| 4745 | + struct i40e_netdev_priv *np = netdev_priv(netdev); |
|---|
| 4746 | + struct i40e_pf *pf = np->vsi->back; |
|---|
| 4747 | + struct i40e_eth_stats *stats; |
|---|
| 4748 | + struct i40e_vsi *vsi; |
|---|
| 4749 | + struct i40e_vf *vf; |
|---|
| 4750 | + |
|---|
| 4751 | + /* validate the request */ |
|---|
| 4752 | + if (i40e_validate_vf(pf, vf_id)) |
|---|
| 4753 | + return -EINVAL; |
|---|
| 4754 | + |
|---|
| 4755 | + vf = &pf->vf[vf_id]; |
|---|
| 4756 | + if (!test_bit(I40E_VF_STATE_INIT, &vf->vf_states)) { |
|---|
| 4757 | + dev_err(&pf->pdev->dev, "VF %d in reset. Try again.\n", vf_id); |
|---|
| 4758 | + return -EBUSY; |
|---|
| 4759 | + } |
|---|
| 4760 | + |
|---|
| 4761 | + vsi = pf->vsi[vf->lan_vsi_idx]; |
|---|
| 4762 | + if (!vsi) |
|---|
| 4763 | + return -EINVAL; |
|---|
| 4764 | + |
|---|
| 4765 | + i40e_update_eth_stats(vsi); |
|---|
| 4766 | + stats = &vsi->eth_stats; |
|---|
| 4767 | + |
|---|
| 4768 | + memset(vf_stats, 0, sizeof(*vf_stats)); |
|---|
| 4769 | + |
|---|
| 4770 | + vf_stats->rx_packets = stats->rx_unicast + stats->rx_broadcast + |
|---|
| 4771 | + stats->rx_multicast; |
|---|
| 4772 | + vf_stats->tx_packets = stats->tx_unicast + stats->tx_broadcast + |
|---|
| 4773 | + stats->tx_multicast; |
|---|
| 4774 | + vf_stats->rx_bytes = stats->rx_bytes; |
|---|
| 4775 | + vf_stats->tx_bytes = stats->tx_bytes; |
|---|
| 4776 | + vf_stats->broadcast = stats->rx_broadcast; |
|---|
| 4777 | + vf_stats->multicast = stats->rx_multicast; |
|---|
| 4778 | + vf_stats->rx_dropped = stats->rx_discards; |
|---|
| 4779 | + vf_stats->tx_dropped = stats->tx_discards; |
|---|
| 4780 | + |
|---|
| 4781 | + return 0; |
|---|
| 4782 | +} |
|---|