target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c
static int rtl930x_pie_verify_template(struct rtl838x_switch_priv *priv,
				       struct pie_rule *pr, int t, int block)
{
	int i;

	if (!pr->is_ipv6 && pr->sip_m && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SIP0))
		return -1;

	if (!pr->is_ipv6 && pr->dip_m && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DIP0))
		return -1;

	if (pr->is_ipv6) {
		if ((pr->sip6_m.s6_addr32[0] || pr->sip6_m.s6_addr32[1]
			|| pr->sip6_m.s6_addr32[2] || pr->sip6_m.s6_addr32[3])
			&& !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SIP2))
			return -1;
		if ((pr->dip6_m.s6_addr32[0] || pr->dip6_m.s6_addr32[1]
			|| pr->dip6_m.s6_addr32[2] || pr->dip6_m.s6_addr32[3])
			&& !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DIP2))
			return -1;
	}

	if (ether_addr_to_u64(pr->smac) && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SMAC0))
		return -1;

	if (ether_addr_to_u64(pr->dmac) && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0))
		return -1;

	// TODO: Check more

	i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE);

	if (i >= PIE_BLOCK_SIZE)
		return -1;

	return i + PIE_BLOCK_SIZE * block;
}
/*
 * Verify that the rule pr is compatible with a given template t in block block
 * Note that this function is SoC specific since the values of e.g. TEMPLATE_FIELD_SIP0
 * depend on the SoC
 */
Verify that the rule pr is compatible with a given template t in block block
Note that this function is SoC specific since the values of e.g.
Verify that the rule pr is compatible with a given template t in block block Note that this function is SoC specific since the values of e . g .
static int rtl930x_pie_verify_template(struct rtl838x_switch_priv *priv,
				       struct pie_rule *pr, int t, int block)
{
	int i;
	if (!pr->is_ipv6 && pr->sip_m && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SIP0))
		return -1;
	if (!pr->is_ipv6 && pr->dip_m && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DIP0))
		return -1;
	if (pr->is_ipv6) {
		if ((pr->sip6_m.s6_addr32[0] || pr->sip6_m.s6_addr32[1]
			|| pr->sip6_m.s6_addr32[2] || pr->sip6_m.s6_addr32[3])
			&& !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SIP2))
			return -1;
		if ((pr->dip6_m.s6_addr32[0] || pr->dip6_m.s6_addr32[1]
			|| pr->dip6_m.s6_addr32[2] || pr->dip6_m.s6_addr32[3])
			&& !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DIP2))
			return -1;
	}
	if (ether_addr_to_u64(pr->smac) && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_SMAC0))
		return -1;
	if (ether_addr_to_u64(pr->dmac) && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0))
		return -1;
	i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE);
	if (i >= PIE_BLOCK_SIZE)
		return -1;
	return i + PIE_BLOCK_SIZE * block;
}
static int rtl930x_pie_verify_template ( struct rtl838x_switch_priv * priv , struct pie_rule * pr , int t , int block ) { int i ; if ( ! pr -> is_ipv6 && pr -> sip_m && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_SIP0 ) ) return -1 ; if ( ! pr -> is_ipv6 && pr -> dip_m && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_DIP0 ) ) return -1 ; if ( pr -> is_ipv6 ) { if ( ( pr -> sip6_m . s6_addr32 [ 0 ] || pr -> sip6_m . s6_addr32 [ 1 ] || pr -> sip6_m . s6_addr32 [ 2 ] || pr -> sip6_m . s6_addr32 [ 3 ] ) && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_SIP2 ) ) return -1 ; if ( ( pr -> dip6_m . s6_addr32 [ 0 ] || pr -> dip6_m . s6_addr32 [ 1 ] || pr -> dip6_m . s6_addr32 [ 2 ] || pr -> dip6_m . s6_addr32 [ 3 ] ) && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_DIP2 ) ) return -1 ; } if ( ether_addr_to_u64 ( pr -> smac ) && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_SMAC0 ) ) return -1 ; if ( ether_addr_to_u64 ( pr -> dmac ) && ! rtl930x_pie_templ_has ( t , TEMPLATE_FIELD_DMAC0 ) ) return -1 ; i = find_first_zero_bit ( & priv -> pie_use_bm [ block * 4 ] , PIE_BLOCK_SIZE ) ; if ( i >= PIE_BLOCK_SIZE ) return -1 ; return i + PIE_BLOCK_SIZE * block ; }
Verify that the rule pr is compatible with a given template t in block block
 Note that this function is SoC specific since the values of e.g.
Verify that the rule pr is compatible with a given template t in block block Note that this function is SoC specific since the values of e . g .
// TODO: Check more