Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1015601rdb; Fri, 19 Jan 2024 05:55:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdrDx3zb+LZUzKQP4M2tEmxbRXgtwVW2GPiJ6NrSuTPaiIhmEn6S7qqkMy0mrhAPK5/T9b X-Received: by 2002:a17:902:8f98:b0:1d7:17e6:44fb with SMTP id z24-20020a1709028f9800b001d717e644fbmr1281948plo.32.1705672551907; Fri, 19 Jan 2024 05:55:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705672551; cv=pass; d=google.com; s=arc-20160816; b=e9PsQHwoKEQPch7+Ob0RH0hRZ8fnWyW0AJLObv0tLUtdFq8fo1UNrQr9CFzOj95oJG ECpz1Svza5H8VDuhMg0698tT8dgQzQZ+hnfTSRKko9YZss01Db2MMgihlVi2pZrbqqiS eJHv2aORY2FbZG2BeYlBq5knY2rZKAnlx2L+FZw6O5d1aaY7E2vobs7afBHrDTANCOe8 PYNpZ9J4ajJ69Eo7IfBNV/LUbx/QVwRsy+ZPbVhDmEgrhYHIzZvZPWuvb7TfSFIxEZT2 7YSWGqWpM8V+zFD7g5YrFQDAsJJoyIzjcC9CbZo4xMQfZ+JwKtNm6hC4/OcyiQdK3Ydf 1OEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=skaTrSJoGr5je0d0+ifzxX2E8sgZBBRCDqE/kQ39ges=; fh=L3f2u8mIbO5EC1D8enc8zg0LCKNVgXEx4FLfDxuKRO8=; b=T5YPWo9AAHzT0BJ6/zFV68izOugzZFqx4pmZT2xbp7T9TxkC5QlRP0Xseyl4cqtqex OBxpVeSFdS+VHOCImzxngbnryz39mPFmUYMBvphWozs7VZHH478H7KWGOka3w3CI90WU baZ6balQ6fZ3PpSxfvUa6eV46UAUjoA9GRHk49ZWNoV2mPDlKk4EkoNhxJe8d8rBCxYJ 4QLmLqisQsw0NXZz95Z0vNm/E2yfo9c9wxilP2V5iiB4B7lbvvp/sn2tHLqzqB5A/+i9 n7QTcuXe0XpzcPL0Nl4T12ENaXV0sl0mM0dIt9B30XoEZ0pyDnXKGSAnW1t9r/HM/cbL bmnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=dRit8dWf; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-31228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u22-20020a63ef16000000b00563de199314si3441100pgh.896.2024.01.19.05.55.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 05:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=dRit8dWf; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-31228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9E65BB225DE for ; Fri, 19 Jan 2024 13:55:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AA7C537F6; Fri, 19 Jan 2024 13:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="dRit8dWf" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5353451C58; Fri, 19 Jan 2024 13:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705672533; cv=none; b=YOZhu6tFtjdORSr5xvlmsowkyJry2P2lMyktKEAjE1YuS7aDXigFb78f51pyJfb07mMZXhHYGKP7YlGGoyqWDIcOHya0CdHHd0dCcaoVTTYNrx2RjYg9CFUTsQjeAvZjfPkpfXS9gXE+6P6cqX8nzqI2UJE7YbN5bT8lk3+gC8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705672533; c=relaxed/simple; bh=LyIQY1yLmMCzSBVpBqm9/JFsE9KeHDEBVBV7Xf+LJGU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g93KCiOrjBOBC3Ac9gAU2vOSzy04dpktTTHy7D3JLeYojJ+GHAAudLsl5JQyregC4smZLHPWD2kzOuFri6MXH9wP6zWQfv+wHU7zluGL2S1i8OBbqemjdJGbdev0LhbwaodaQJSBOdo1/7azDoMBo0E0RTb8PUXXxH7SJ66wymQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=dRit8dWf; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=skaTrSJoGr5je0d0+ifzxX2E8sgZBBRCDqE/kQ39ges=; b=dRit8dWfQ4NVAxSNdkyw9rG0vP pp/lsE2CNpxrr40AoigbgsUjdkh1ZE1eJIBVEjXr5Ubxt8lpoaKl7hfnYT3k3SDE+Y8+OdF4yFWcR 68Xdax9i4BVM5zFxPbDv7lnlcWodGZdELO1yGjmCGn44+WfZ2b/lEGMAo353RIm5/SoU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1rQpKu-005Ywd-4s; Fri, 19 Jan 2024 14:55:08 +0100 Date: Fri, 19 Jan 2024 14:55:08 +0100 From: Andrew Lunn To: MD Danish Anwar Cc: Rob Herring , Dan Carpenter , Jan Kiszka , Vladimir Oltean , Wolfram Sang , Arnd Bergmann , Grygorii Strashko , Vignesh Raghavendra , Roger Quadros , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, srk@ti.com, r-gunasekaran@ti.com Subject: Re: [RFC PATCH v2 1/3] net: ti: icssg-prueth: Add helper functions to configure FDB Message-ID: References: <20240118071005.1514498-1-danishanwar@ti.com> <20240118071005.1514498-2-danishanwar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240118071005.1514498-2-danishanwar@ti.com> > +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