211 /*
212 * Enable and disable promiscuous mode as requested. We have to toggle both
213 * unicast and multicast. Note that multicast may already be enabled due to the
214 * i40e_m_multicast may toggle it itself. See i40e_main.c for more information
215 * on this.
216 */
217 static int
218 i40e_m_promisc(void *arg, boolean_t on)
219 {
220 i40e_t *i40e = arg;
221 struct i40e_hw *hw = &i40e->i40e_hw_space;
222 int ret = 0, err = 0;
223
224 mutex_enter(&i40e->i40e_general_lock);
225 if (i40e->i40e_state & I40E_SUSPENDED) {
226 ret = ECANCELED;
227 goto done;
228 }
229
230
231 ret = i40e_aq_set_vsi_unicast_promiscuous(hw, I40E_DEF_VSI_SEID(i40e),
232 on, NULL, B_FALSE);
233 if (ret != I40E_SUCCESS) {
234 i40e_error(i40e, "failed to %s unicast promiscuity on "
235 "the default VSI: %d", on == B_TRUE ? "enable" : "disable",
236 ret);
237 err = EIO;
238 goto done;
239 }
240
241 /*
242 * If we have a non-zero mcast_promisc_count, then it has already been
243 * enabled or we need to leave it that way and not touch it.
244 */
245 if (i40e->i40e_mcast_promisc_count > 0) {
246 i40e->i40e_promisc_on = on;
247 goto done;
248 }
249
250 ret = i40e_aq_set_vsi_multicast_promiscuous(hw, I40E_DEF_VSI_SEID(i40e),
254 "the default VSI: %d", on == B_TRUE ? "enable" : "disable",
255 ret);
256
257 /*
258 * Try our best to put us back into a state that MAC expects us
259 * to be in.
260 */
261 ret = i40e_aq_set_vsi_unicast_promiscuous(hw,
262 I40E_DEF_VSI_SEID(i40e), !on, NULL, B_FALSE);
263 if (ret != I40E_SUCCESS) {
264 i40e_error(i40e, "failed to %s unicast promiscuity on "
265 "the default VSI after toggling multicast failed: "
266 "%d", on == B_TRUE ? "disable" : "enable", ret);
267 }
268
269 err = EIO;
270 goto done;
271 } else {
272 i40e->i40e_promisc_on = on;
273 }
274
275 done:
276 mutex_exit(&i40e->i40e_general_lock);
277 return (err);
278 }
279
280 /*
281 * See the big theory statement in i40e_main.c for multicast address management.
282 */
283 static int
284 i40e_multicast_add(i40e_t *i40e, const uint8_t *multicast_address)
285 {
286 struct i40e_hw *hw = &i40e->i40e_hw_space;
287 struct i40e_aqc_add_macvlan_element_data filt;
288 i40e_maddr_t *mc;
289 int ret;
290
291 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock));
292
293 if (i40e->i40e_resources.ifr_nmcastfilt_used ==
|
211 /*
212 * Enable and disable promiscuous mode as requested. We have to toggle both
213 * unicast and multicast. Note that multicast may already be enabled due to the
214 * i40e_m_multicast may toggle it itself. See i40e_main.c for more information
215 * on this.
216 */
217 static int
218 i40e_m_promisc(void *arg, boolean_t on)
219 {
220 i40e_t *i40e = arg;
221 struct i40e_hw *hw = &i40e->i40e_hw_space;
222 int ret = 0, err = 0;
223
224 mutex_enter(&i40e->i40e_general_lock);
225 if (i40e->i40e_state & I40E_SUSPENDED) {
226 ret = ECANCELED;
227 goto done;
228 }
229
230
231 #if 1
232 /*
233 * XXX KEBE SAYS try this from Linux...
234 *
235 * Their comment says:
236 *
237 * set defport ON for Main VSI instead of true promisc
238 * this way we will get all unicast/multicast and VLAN
239 * promisc behavior but will not get VF or VMDq traffic
240 * replicated on the Main VSI.
241 */
242
243 ret = on ? i40e_aq_set_default_vsi(hw, I40E_DEF_VSI_SEID(i40e), NULL) :
244 i40e_aq_clear_default_vsi(hw, I40E_DEF_VSI_SEID(i40e), NULL);
245 if (ret == I40E_SUCCESS)
246 i40e->i40e_promisc_on = on;
247 else
248 err = EIO;
249 #else
250 ret = i40e_aq_set_vsi_unicast_promiscuous(hw, I40E_DEF_VSI_SEID(i40e),
251 on, NULL, B_FALSE);
252 if (ret != I40E_SUCCESS) {
253 i40e_error(i40e, "failed to %s unicast promiscuity on "
254 "the default VSI: %d", on == B_TRUE ? "enable" : "disable",
255 ret);
256 err = EIO;
257 goto done;
258 }
259
260 /*
261 * If we have a non-zero mcast_promisc_count, then it has already been
262 * enabled or we need to leave it that way and not touch it.
263 */
264 if (i40e->i40e_mcast_promisc_count > 0) {
265 i40e->i40e_promisc_on = on;
266 goto done;
267 }
268
269 ret = i40e_aq_set_vsi_multicast_promiscuous(hw, I40E_DEF_VSI_SEID(i40e),
273 "the default VSI: %d", on == B_TRUE ? "enable" : "disable",
274 ret);
275
276 /*
277 * Try our best to put us back into a state that MAC expects us
278 * to be in.
279 */
280 ret = i40e_aq_set_vsi_unicast_promiscuous(hw,
281 I40E_DEF_VSI_SEID(i40e), !on, NULL, B_FALSE);
282 if (ret != I40E_SUCCESS) {
283 i40e_error(i40e, "failed to %s unicast promiscuity on "
284 "the default VSI after toggling multicast failed: "
285 "%d", on == B_TRUE ? "disable" : "enable", ret);
286 }
287
288 err = EIO;
289 goto done;
290 } else {
291 i40e->i40e_promisc_on = on;
292 }
293 #endif
294
295 done:
296 mutex_exit(&i40e->i40e_general_lock);
297 return (err);
298 }
299
300 /*
301 * See the big theory statement in i40e_main.c for multicast address management.
302 */
303 static int
304 i40e_multicast_add(i40e_t *i40e, const uint8_t *multicast_address)
305 {
306 struct i40e_hw *hw = &i40e->i40e_hw_space;
307 struct i40e_aqc_add_macvlan_element_data filt;
308 i40e_maddr_t *mc;
309 int ret;
310
311 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock));
312
313 if (i40e->i40e_resources.ifr_nmcastfilt_used ==
|