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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ad5c31cc-7cb6-4791-86fe-b2ba30abf33e@ti.com>
Date: Mon, 22 Jan 2024 16:18:43 +0530
From: MD Danish Anwar <danishanwar@...com>
To: Andrew Lunn <andrew@...n.ch>
CC: Rob Herring <robh@...nel.org>, Dan Carpenter <dan.carpenter@...aro.org>,
        Jan Kiszka <jan.kiszka@...mens.com>,
        Vladimir Oltean
	<vladimir.oltean@....com>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        Arnd Bergmann <arnd@...db.de>, Vignesh Raghavendra <vigneshr@...com>,
        Roger
 Quadros <rogerq@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski
	<kuba@...nel.org>, Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller"
	<davem@...emloft.net>,
        <linux-arm-kernel@...ts.infradead.org>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <srk@...com>, <r-gunasekaran@...com>
Subject: Re: [RFC PATCH v2 1/3] net: ti: icssg-prueth: Add helper functions to
 configure FDB



On 19/01/24 7:25 pm, Andrew Lunn wrote:
>> +int icssg_fdb_add_del(struct prueth_emac *emac, const unsigned char *addr,
>> +		      u8 vid, u8 fid_c2, bool add)
>> +{
>> +
>> +	for (i = 0; i < ETH_ALEN; i++)
>> +		mac_fid[i] = addr[i];
> 
> ether_addr_copy()

Sure.

> 
>> +
>> +	/* 1-1 VID-FID mapping is already setup */
>> +	mac_fid[ETH_ALEN] = fid;
>> +	mac_fid[ETH_ALEN + 1] = 0;
>> +
>> +	fdb_slot = bitrev32(crc32_le(0, mac_fid, 8)) & PRUETH_SWITCH_FDB_MASK;
>> +
> 
>> +	fid_c2 |= ICSSG_FDB_ENTRY_VALID;
>> +	memcpy(&fdb_cmd.cmd_args[0], addr, 4);
>> +	memcpy(&fdb_cmd.cmd_args[1], &addr[4], 2);
>> +	fdb_cmd.cmd_args[1] |= ((fid << 16) | (fid_c2 << 24));
>> +	fdb_cmd.cmd_args[2] = fdb_slot;
> 
>> +int icssg_fdb_lookup(struct prueth_emac *emac, const unsigned char *addr,
>> +		     u8 vid)
>> +{
> 
>> +	for (i = 0; i < ETH_ALEN; i++)
>> +		mac_fid[i] = addr[i];
>> +
>> +	/* 1-1 VID-FID mapping is already setup */
>> +	mac_fid[ETH_ALEN] = fid;
>> +	mac_fid[ETH_ALEN + 1] = 0;
> 
>> +	memcpy(&fdb_cmd.cmd_args[0], addr, 4);
>> +	memcpy(&fdb_cmd.cmd_args[1], &addr[4], 2);
>> +	fdb_cmd.cmd_args[1] |= fid << 16;
>> +	fdb_cmd.cmd_args[2] = fdb_slot;
> 
> Maybe add some helpers to reduce the amount of duplicated code?
> 

Some codes are duplicated in icssg_fdb_add_del() and icssg_fdb_lookup().
I'll try to add helpers in next version to minimize this.

>       Andrew

-- 
Thanks and Regards,
Danish

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ