[PATCH net-next v4 1/6] net: dcb: add new pcp selector to app object

Petr Machata petrm at nvidia.com
Mon Oct 31 04:13:43 PDT 2022


Daniel Machon <daniel.machon at microchip.com> writes:

> diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
> index dc4fb699b56c..68e033a459af 100644
> --- a/net/dcb/dcbnl.c
> +++ b/net/dcb/dcbnl.c
> @@ -179,6 +179,57 @@ static const struct nla_policy dcbnl_featcfg_nest[DCB_FEATCFG_ATTR_MAX + 1] = {
>  static LIST_HEAD(dcb_app_list);
>  static DEFINE_SPINLOCK(dcb_lock);
>  
> +static enum ieee_attrs_app dcbnl_app_attr_type_get(u8 selector)
> +{
> +	switch (selector) {
> +	case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
> +	case IEEE_8021QAZ_APP_SEL_STREAM:
> +	case IEEE_8021QAZ_APP_SEL_DGRAM:
> +	case IEEE_8021QAZ_APP_SEL_ANY:
> +	case IEEE_8021QAZ_APP_SEL_DSCP:
> +		return DCB_ATTR_IEEE_APP;
> +	case DCB_APP_SEL_PCP:
> +		return DCB_ATTR_DCB_APP;
> +	default:
> +		return DCB_ATTR_IEEE_APP_UNSPEC;
> +	}
> +}
> +
> +static bool dcbnl_app_attr_type_validate(enum ieee_attrs_app type)
> +{
> +	switch (type) {
> +	case DCB_ATTR_IEEE_APP:
> +	case DCB_ATTR_DCB_APP:
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +static bool dcbnl_app_selector_validate(enum ieee_attrs_app type, u32 selector)
> +{
> +	switch (selector) {
> +	case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
> +	case IEEE_8021QAZ_APP_SEL_STREAM:
> +	case IEEE_8021QAZ_APP_SEL_DGRAM:
> +	case IEEE_8021QAZ_APP_SEL_ANY:
> +	case IEEE_8021QAZ_APP_SEL_DSCP:
> +		/* IEEE std selectors in IEEE std attribute */
> +		if (type == DCB_ATTR_IEEE_APP)
> +			return true;
> +		else
> +			return false;

AKA return type == DCB_ATTR_IEEE_APP;

> +	case DCB_APP_SEL_PCP:
> +		/* Non-std selectors in non-std attribute */
> +		if (type == DCB_ATTR_DCB_APP)
> +			return true;
> +		else
> +			return false;

Likewise here.

> +	default:
> +		return false;
> +	}

Also, it really looks like the following would be equivalent?

static bool dcbnl_app_selector_validate(enum ieee_attrs_app type, u32 selector)
{
	return dcbnl_app_attr_type_get(selector) == type;
}

Also, shouldn't it be u8 selector?

> +}
> +
>  static struct sk_buff *dcbnl_newmsg(int type, u8 cmd, u32 port, u32 seq,
>  				    u32 flags, struct nlmsghdr **nlhp)
>  {



More information about the linux-arm-kernel mailing list