Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp244472rdb; Mon, 22 Jan 2024 02:49:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhumRLFHukATRNFEOi8oaWALsgGru5KyieKXjEBlvlBX7D4JJNSh64WqZaESvy6XOKCGbK X-Received: by 2002:a17:902:8216:b0:1d4:7d37:d448 with SMTP id x22-20020a170902821600b001d47d37d448mr5090543pln.44.1705920588182; Mon, 22 Jan 2024 02:49:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705920588; cv=pass; d=google.com; s=arc-20160816; b=0sQEBJMf6O3t8hwx+gIJvdQ1eGYZ9h9hLOYid+yTiGKM3AUYx/H4k5QXW4QzcCN2HX JeSDktD0MgUO4tAP68+XdzV0aVwwqYS+gkMXnJwIRz21wTTC/Cs5u7cYOjKSlwt3zX/W LL0DQ66MF6RuU2PsskU73rgy19rTaEct/9jhTLRmHiMvCLF79RWJqOaxFsbJb988xCW8 8+AgWQebd59xYNvhwszXIlqOlJtcp7SB5dzJrvIozphzho+S1QiUiHlHs9ZId8UDWMT1 w/zkWfhUYzM0xvXUKw2XuoA6BXT2xdbtrJBHWdjBXHk57pDDp20UCM5GocO2uNjVtGgX gT+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=BJya4J7U2wsMIZQXgChP3PwMJktx8r9T37jW6na+29g=; fh=3Rupv5qWzHF2WBor+PmvZeKbeJzhw7uQDRhL4vo2Yjo=; b=bJI0iNjX5CQ/Ss1sFdjXMjeewyZh+wNRARANyHZJdIT2FrBEYLXxzD0KMj58w9yPpb sxhbeecYOStnEz31hgLxLqw6W8NKRmAEZK4c2gYpnBbH9qwilPZ9lYFUDiofHOsUw0fO ePO92y4ph3JOQx0Yi+dkhdv6s4TZcYpeCH25zcIc9ekfqLqEdoMUXPnrpUAElPy1Ts/p 7hfNSAIMdkAJ7vfdsWPyl8HmnDly8lOwKWW5U1Q2cp+BbWaAGrR1LMnPTtvsCQlzTmHl QwZu2fQIxIlrHJ7mMQVAPMOuk9bJYS6SmtVgKVb6Z2qg068V24dac0MIYrrw9TUwhPAy 2+hA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AeP7C9p8; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-32785-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h15-20020a170902680f00b001d54b66517asi7906395plk.388.2024.01.22.02.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:49:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32785-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=AeP7C9p8; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-32785-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32785-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CCEE028666D for ; Mon, 22 Jan 2024 10:49:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CFBB3A27B; Mon, 22 Jan 2024 10:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="AeP7C9p8" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 09CBA3A8C3; Mon, 22 Jan 2024 10:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705920551; cv=none; b=o/KN4NI3Go7Pe8GdXfQjZE59oGcOU7UkU3fUgcSGeO15Io5i+q6QCom3QPZKfFhbTHEHMrf6N03Y3Jyaz7Bvo983PaAMFPy82UyWGi+SEScu8VGJcjuCLv9dsnhWbl8J9rR2pB76V0tF49qYoUp/xx5XRUFAQcYPeNkQdnTABpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705920551; c=relaxed/simple; bh=G/7NfDFOlqtjKjUrpbty5x9de3dLn4eUQJxwgMCjSdA=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=GZ4G5pdeoIlCPM4XjkATBhVSX/zAiFVvYgtwHOKnpj7Ly85/YKizJDNFGVmJVyAYZ1S34cx3WGwyTsI21Eqzpl3Zcyy910TnaiGDUa4hC5QAGhCNZHwN25qhCPHc3IqEvAcpzgD1TvO+5aZBKVMmsL64QxW/k6TaWggR/wJYDM8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=AeP7C9p8; arc=none smtp.client-ip=198.47.23.248 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40MAmoUX116000; Mon, 22 Jan 2024 04:48:50 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1705920530; bh=BJya4J7U2wsMIZQXgChP3PwMJktx8r9T37jW6na+29g=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=AeP7C9p820x3uyj/qwJyH4LKUX3cRh2wjwSINg5BwXaqc9Sl+Wj1OCR+aA6ZBdBX4 HoVKTa95ZtCevUftW2jQa0oV78e80VNnAaJQTeY/kMYQu6Rh6fdt7SgG+/qmKGQruO QmZ3vfj+sq/DFYyy0OvEadQ43uYa6zUGiqN1Ak20= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40MAmnW8015586 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Jan 2024 04:48:50 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 22 Jan 2024 04:48:49 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 22 Jan 2024 04:48:49 -0600 Received: from [10.24.69.25] (danish-tpc.dhcp.ti.com [10.24.69.25]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40MAmiYU061813; Mon, 22 Jan 2024 04:48:44 -0600 Message-ID: Date: Mon, 22 Jan 2024 16:18:43 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 1/3] net: ti: icssg-prueth: Add helper functions to configure FDB Content-Language: en-US To: Andrew Lunn CC: Rob Herring , Dan Carpenter , Jan Kiszka , Vladimir Oltean , Wolfram Sang , Arnd Bergmann , Vignesh Raghavendra , Roger Quadros , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , , , , , References: <20240118071005.1514498-1-danishanwar@ti.com> <20240118071005.1514498-2-danishanwar@ti.com> From: MD Danish Anwar In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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