lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 7 Dec 2017 00:23:06 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Tristram.Ha@...rochip.com
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        Pavel Machek <pavel@....cz>,
        Ruediger Schmitt <ruediger.schmitt@...lips.com>,
        muvarov@...il.com, nathan.leigh.conrad@...il.com,
        vivien.didelot@...oirfairelinux.com, UNGLinuxDriver@...rochip.com,
        netdev@...r.kernel.org
Subject: Re: [PATCH v3 net-next] net: dsa: Modify tag_ksz.c so that tail tag
 code can be used by other KSZ switch drivers

On Tue, Dec 05, 2017 at 05:47:14PM -0800, Tristram.Ha@...rochip.com wrote:
> +static int ksz9477_get_tag(u8 *tag, int *port)
> +{
> +	*port = tag[0] & 7;
> +	return KSZ_EGRESS_TAG_LEN;
> +}
> +
> +static void ksz9477_set_tag(void *ptr, u8 *addr, int p)
> +{
> +	u16 *tag = (u16 *)ptr;
> +
> +	*tag = 1 << p;
> +	*tag = cpu_to_be16(*tag);
> +}

Hi Tristram

It would be more normal to create an ops structure

struct ksz_tag_ops {
       int (*get_tag)(u8 *tag, int *port);
       void (*set_tag)(void *ptr, u8 *addr, int p)
};

static const struct ksz_tag_ops ksz9477_tag_ops = {
       .get_tag = ksz9477_get_tag,
       .set_tag = ksz9477_set_tag,
}

and then pass this to the functions.

It might even be possible to make this more generic, use it for other
tag drivers.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ