src/dpdk/drivers/net/i40e/i40e_ethdev.c
int
i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
{
	int i, num;
	struct i40e_mac_filter *f;
	void *temp;
	struct i40e_mac_filter_info *mac_filter;
	enum i40e_mac_filter_type desired_filter;
	int ret = I40E_SUCCESS;

	if (on) {
		/* Filter to match MAC and VLAN */
		desired_filter = I40E_MACVLAN_PERFECT_MATCH;
	} else {
		/* Filter to match only MAC */
		desired_filter = I40E_MAC_PERFECT_MATCH;
	}

	num = vsi->mac_num;

	mac_filter = rte_zmalloc("mac_filter_info_data",
				 num * sizeof(*mac_filter), 0);
	if (mac_filter == NULL) {
		PMD_DRV_LOG(ERR, "failed to allocate memory");
		return I40E_ERR_NO_MEMORY;
	}

	i = 0;

	/* Remove all existing mac */
	TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) {
		mac_filter[i] = f->mac_info;
		ret = i40e_vsi_delete_mac(vsi, &f->mac_info.mac_addr);
		if (ret) {
			PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
				    on ? "enable" : "disable");
			goto DONE;
		}
		i++;
	}

	/* Override with new filter */
	for (i = 0; i < num; i++) {
		mac_filter[i].filter_type = desired_filter;
		ret = i40e_vsi_add_mac(vsi, &mac_filter[i]);
		if (ret) {
			PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
				    on ? "enable" : "disable");
			goto DONE;
		}
	}

DONE:
	rte_free(mac_filter);
	return ret;
}
/* Configure vlan filter on or off */
Configure vlan filter on or off
Configure vlan filter on or off
int
i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
{
	int i, num;
	struct i40e_mac_filter *f;
	void *temp;
	struct i40e_mac_filter_info *mac_filter;
	enum i40e_mac_filter_type desired_filter;
	int ret = I40E_SUCCESS;
	if (on) {
		desired_filter = I40E_MACVLAN_PERFECT_MATCH;
	} else {
		desired_filter = I40E_MAC_PERFECT_MATCH;
	}
	num = vsi->mac_num;
	mac_filter = rte_zmalloc("mac_filter_info_data",
				 num * sizeof(*mac_filter), 0);
	if (mac_filter == NULL) {
		PMD_DRV_LOG(ERR, "failed to allocate memory");
		return I40E_ERR_NO_MEMORY;
	}
	i = 0;
	TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) {
		mac_filter[i] = f->mac_info;
		ret = i40e_vsi_delete_mac(vsi, &f->mac_info.mac_addr);
		if (ret) {
			PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
				    on ? "enable" : "disable");
			goto DONE;
		}
		i++;
	}
	for (i = 0; i < num; i++) {
		mac_filter[i].filter_type = desired_filter;
		ret = i40e_vsi_add_mac(vsi, &mac_filter[i]);
		if (ret) {
			PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
				    on ? "enable" : "disable");
			goto DONE;
		}
	}
DONE:
	rte_free(mac_filter);
	return ret;
}
int i40e_vsi_config_vlan_filter ( struct i40e_vsi * vsi , bool on ) { int i , num ; struct i40e_mac_filter * f ; void * temp ; struct i40e_mac_filter_info * mac_filter ; enum i40e_mac_filter_type desired_filter ; int ret = I40E_SUCCESS ; if ( on ) { desired_filter = I40E_MACVLAN_PERFECT_MATCH ; } else { desired_filter = I40E_MAC_PERFECT_MATCH ; } num = vsi -> mac_num ; mac_filter = rte_zmalloc ( " " , num * sizeof ( * mac_filter ) , 0 ) ; if ( mac_filter == NULL ) { PMD_DRV_LOG ( ERR , " " ) ; return I40E_ERR_NO_MEMORY ; } i = 0 ; TAILQ_FOREACH_SAFE ( f , & vsi -> mac_list , next , temp ) { mac_filter [ i ] = f -> mac_info ; ret = i40e_vsi_delete_mac ( vsi , & f -> mac_info . mac_addr ) ; if ( ret ) { PMD_DRV_LOG ( ERR , " " , on ? " " : " " ) ; goto DONE ; } i ++ ; } for ( i = 0 ; i < num ; i ++ ) { mac_filter [ i ] . filter_type = desired_filter ; ret = i40e_vsi_add_mac ( vsi , & mac_filter [ i ] ) ; if ( ret ) { PMD_DRV_LOG ( ERR , " " , on ? " " : " " ) ; goto DONE ; } } DONE : rte_free ( mac_filter ) ; return ret ; }
Configure vlan filter on or off
Configure vlan filter on or off
/* Filter to match MAC and VLAN */ /* Filter to match only MAC */ /* Remove all existing mac */ /* Override with new filter */