src/dpdk/drivers/net/cxgbe/cxgbe_filter.c
int cxgbe_validate_filter(struct adapter *adapter,
			  struct ch_filter_specification *fs)
{
	u32 fconf, iconf;

	/*
	 * Check for unconfigured fields being used.
	 */
	fconf = fs->cap ? adapter->params.tp.filter_mask :
			  adapter->params.tp.vlan_pri_map;

	iconf = adapter->params.tp.ingress_config;

#define S(_field) \
	(fs->val._field || fs->mask._field)
#define U(_mask, _field) \
	(!(fconf & (_mask)) && S(_field))

	if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) ||
	    U(F_PROTOCOL, proto) || U(F_MACMATCH, macidx) ||
	    U(F_VLAN, ivlan_vld) || U(F_VNIC_ID, ovlan_vld) ||
	    U(F_TOS, tos) || U(F_VNIC_ID, pfvf_vld))
		return -EOPNOTSUPP;

	/* Either OVLAN or PFVF match is enabled in hardware, but not both */
	if ((S(pfvf_vld) && !(iconf & F_VNIC)) ||
	    (S(ovlan_vld) && (iconf & F_VNIC)))
		return -EOPNOTSUPP;

	/* To use OVLAN or PFVF, L4 encapsulation match must not be enabled */
	if ((S(ovlan_vld) && (iconf & F_USE_ENC_IDX)) ||
	    (S(pfvf_vld) && (iconf & F_USE_ENC_IDX)))
		return -EOPNOTSUPP;

#undef S
#undef U

	/*
	 * If the user is requesting that the filter action loop
	 * matching packets back out one of our ports, make sure that
	 * the egress port is in range.
	 */
	if (fs->action == FILTER_SWITCH &&
	    fs->eport >= adapter->params.nports)
		return -ERANGE;

	/*
	 * Don't allow various trivially obvious bogus out-of-range
	 * values ...
	 */
	if (fs->val.iport >= adapter->params.nports)
		return -ERANGE;

	if (!fs->cap && fs->nat_mode && !adapter->params.filter2_wr_support)
		return -EOPNOTSUPP;

	if (!fs->cap && fs->swapmac && !adapter->params.filter2_wr_support)
		return -EOPNOTSUPP;

	return 0;
}
/**
 * Validate if the requested filter specification can be set by checking
 * if the requested features have been enabled
 */
Validate if the requested filter specification can be set by checking
if the requested features have been enabled
Validate if the requested filter specification can be set by checking if the requested features have been enabled
int cxgbe_validate_filter(struct adapter *adapter,
			  struct ch_filter_specification *fs)
{
	u32 fconf, iconf;
	fconf = fs->cap ? adapter->params.tp.filter_mask :
			  adapter->params.tp.vlan_pri_map;
	iconf = adapter->params.tp.ingress_config;
#define S(_field) \
	(fs->val._field || fs->mask._field)
#define U(_mask, _field) \
	(!(fconf & (_mask)) && S(_field))
	if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) ||
	    U(F_PROTOCOL, proto) || U(F_MACMATCH, macidx) ||
	    U(F_VLAN, ivlan_vld) || U(F_VNIC_ID, ovlan_vld) ||
	    U(F_TOS, tos) || U(F_VNIC_ID, pfvf_vld))
		return -EOPNOTSUPP;
	if ((S(pfvf_vld) && !(iconf & F_VNIC)) ||
	    (S(ovlan_vld) && (iconf & F_VNIC)))
		return -EOPNOTSUPP;
	if ((S(ovlan_vld) && (iconf & F_USE_ENC_IDX)) ||
	    (S(pfvf_vld) && (iconf & F_USE_ENC_IDX)))
		return -EOPNOTSUPP;
#undef S
#undef U
	if (fs->action == FILTER_SWITCH &&
	    fs->eport >= adapter->params.nports)
		return -ERANGE;
	if (fs->val.iport >= adapter->params.nports)
		return -ERANGE;
	if (!fs->cap && fs->nat_mode && !adapter->params.filter2_wr_support)
		return -EOPNOTSUPP;
	if (!fs->cap && fs->swapmac && !adapter->params.filter2_wr_support)
		return -EOPNOTSUPP;
	return 0;
}
int cxgbe_validate_filter ( struct adapter * adapter , struct ch_filter_specification * fs ) { u32 fconf , iconf ; fconf = fs -> cap ? adapter -> params . tp . filter_mask : adapter -> params . tp . vlan_pri_map ; iconf = adapter -> params . tp . ingress_config ; #define S ( _field )  \
	(fs->val._field || fs->mask._field) #define U ( _mask , _field )  \
	(!(fconf & (_mask)) && S(_field)) if ( U ( F_PORT , iport ) || U ( F_ETHERTYPE , ethtype ) || U ( F_PROTOCOL , proto ) || U ( F_MACMATCH , macidx ) || U ( F_VLAN , ivlan_vld ) || U ( F_VNIC_ID , ovlan_vld ) || U ( F_TOS , tos ) || U ( F_VNIC_ID , pfvf_vld ) ) return - EOPNOTSUPP ; if ( ( S ( pfvf_vld ) && ! ( iconf & F_VNIC ) ) || ( S ( ovlan_vld ) && ( iconf & F_VNIC ) ) ) return - EOPNOTSUPP ; if ( ( S ( ovlan_vld ) && ( iconf & F_USE_ENC_IDX ) ) || ( S ( pfvf_vld ) && ( iconf & F_USE_ENC_IDX ) ) ) return - EOPNOTSUPP ; #undef  S #undef  U if ( fs -> action == FILTER_SWITCH && fs -> eport >= adapter -> params . nports ) return - ERANGE ; if ( fs -> val . iport >= adapter -> params . nports ) return - ERANGE ; if ( ! fs -> cap && fs -> nat_mode && ! adapter -> params . filter2_wr_support ) return - EOPNOTSUPP ; if ( ! fs -> cap && fs -> swapmac && ! adapter -> params . filter2_wr_support ) return - EOPNOTSUPP ; return 0 ; }
Validate if the requested filter specification can be set by checking
 if the requested features have been enabled
Validate if the requested filter specification can be set by checking if the requested features have been enabled
/*
	 * Check for unconfigured fields being used.
	 */ /* Either OVLAN or PFVF match is enabled in hardware, but not both */ /* To use OVLAN or PFVF, L4 encapsulation match must not be enabled */ /*
	 * If the user is requesting that the filter action loop
	 * matching packets back out one of our ports, make sure that
	 * the egress port is in range.
	 */ /*
	 * Don't allow various trivially obvious bogus out-of-range
	 * values ...
	 */