[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a9c18466-7d7d-4a63-8096-d832bd9e455f@lunn.ch>
Date: Fri, 19 Jan 2024 14:55:08 +0100
From: Andrew Lunn <andrew@...n.ch>
To: MD Danish Anwar <danishanwar@...com>
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>,
Grygorii Strashko <grygorii.strashko@...com>,
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
> +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()
> +
> + /* 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?
Andrew
Powered by blists - more mailing lists