From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84BD7C433F5 for ; Sat, 25 Sep 2021 19:29:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 482846109D for ; Sat, 25 Sep 2021 19:29:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 482846109D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0bcATGVqUngCfcV9BM8htHSsVoTKAECITdlmjUQqbuU=; b=uLKiHcTY8/iqUc 75p9+eY9vz9e6hpKKC5BkD9kFPEp3NfBefx52Zwc8vVwTOFHa+koHIzD/Ot+KY1xcj43WRUU1OW8q eT8vAnyRlXt4qQ5kNwfPnsMdpqNFTcbb6Td+a0vJSkPSOerpP6SVXXsGy9A0TWv6eh0kexIj/2ZZh YNlMsQ/ILnc1TYQaNS9M7twt//RRFadZZ255jA4Jgj56aTjQTbCgNvAhOm8zOxazNLUanHTgCWsrV kV23TbnWASPSEb1S9nk2EJk+I7Yok0y6qCcDyvTPGypuXwPndOX2nKbvfBgnpXrwAMzZ4k0lgAwOh /eNUjpe4v+pSxwCY+EKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUDKQ-00H7M0-Cn; Sat, 25 Sep 2021 19:27:18 +0000 Received: from mail-eopbgr70070.outbound.protection.outlook.com ([40.107.7.70] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUDKL-00H7L8-7r; Sat, 25 Sep 2021 19:27:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDMelngmLJsHMCElPmV7eixtK1VLDQuQ+wIYSb+O+jKtJiJOzl/Ix6NMn1fJwFtB/Q6p5dxPhfYlo5A3sPgBrtHEuqyVKuEO4pcenB1chDGI2W0w/+/2wLHLIqb/D8BOzU2CH+4WU2IcSuniQDH9Etwx+XV/phI3NRSQF3xKPJG3PhlzI3K1NE0U9Xg/8mu634uSbgv9kjt72i8L6JDXLcnN0lGXhnP428CEObwh2GSJtxxQq8bJpn00dm9C065qbbju1ufUyob5ZEAoEpdbOxLZSXE94pT6AY+KPZX8XhjHxnmBBxbuwqYvf6cpRMGeLNmdHnfqHT7wV0l3AJtroA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KJ1vMhSQLCphqvu3AfrZOTeAmOug2seu+xGc5s1iJok=; b=No3z/u91VqkI8SjxGOfXbfYPoJJQcuBm+RfzN9nlpMvz3fGlahtCiKBv6GCKyfax5T5PdCYw/YRky4g34hT9+9ulDrz3i04ZZwu40irW5Aps7H8vEJH1G88Oev63rOmfCmHawZvkui8/E9HCMR5gfgKkoquHrsyrA0B6XpLqbxnl3At+Hoi+Hu3mHIE/X58qya+C4+MaoihAemdEq3zq3rWtXsYkDtX0jEH7LcCOqU/v9/UYqcsTs8W4v4HSUCUDoI+fuisiYbLPCZvwPN9JgsZOxe1SfDd3IIpecvyoUSlHeNbBl0CKRog3Wh0uk6xdkMG/okZ9jHL9bu6wbPDLQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KJ1vMhSQLCphqvu3AfrZOTeAmOug2seu+xGc5s1iJok=; b=Su3dprtl6fo6xMGdb2Wf8zijVPcROxreDpDZ3clzEs4mdDepr7mfJF1ox6s0kLgWCTp+r70XQtNCfJDgLlILXT/K6q8nQNNejcX/Iwhf7lydfFrOEBET97sxxbTlvHQ3BRFYORO/BSET48qOwj7U7fzUu9Vo071dIPk0GYTdWG8= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB2863.eurprd04.prod.outlook.com (2603:10a6:800:af::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Sat, 25 Sep 2021 19:26:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::e157:3280:7bc3:18c4%5]) with mapi id 15.20.4544.020; Sat, 25 Sep 2021 19:26:59 +0000 From: Vladimir Oltean To: Xiaoliang Yang CC: "davem@davemloft.net" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "allan.nielsen@microchip.com" , "joergen.andreasen@microchip.com" , "UNGLinuxDriver@microchip.com" , "vinicius.gomes@intel.com" , "michael.chan@broadcom.com" , "vishal@chelsio.com" , "saeedm@mellanox.com" , "jiri@mellanox.com" , "idosch@mellanox.com" , "alexandre.belloni@bootlin.com" , "kuba@kernel.org" , Po Liu , Leo Li , "f.fainelli@gmail.com" , "andrew@lunn.ch" , "vivien.didelot@gmail.com" , Claudiu Manoil , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "matthias.bgg@gmail.com" , "horatiu.vultur@microchip.com" Subject: Re: [PATCH v5 net-next 3/9] net: mscc: ocelot: add MAC table stream learn and lookup operations Thread-Topic: [PATCH v5 net-next 3/9] net: mscc: ocelot: add MAC table stream learn and lookup operations Thread-Index: AQHXsSiIqyPSbQvi9k+5oHNKLiCyoqu1JEsA Date: Sat, 25 Sep 2021 19:26:59 +0000 Message-ID: <20210925192658.2wi6egpufqut5hsf@skbuf> References: <20210924095226.38079-1-xiaoliang.yang_1@nxp.com> <20210924095226.38079-4-xiaoliang.yang_1@nxp.com> In-Reply-To: <20210924095226.38079-4-xiaoliang.yang_1@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1ad77a97-9411-4dd0-c111-08d9805a71e2 x-ms-traffictypediagnostic: VI1PR0402MB2863: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oIaGUcwjl3TaMx4dqngSGST0G8CkRTsXs7+b/H5UFun972FKUDzmFBV4lnNj5PjMiz7D10sfKbj+1uq0Af1uJjEScdAilO3c38Fr04xQ6FIq/BeX1FPjNvMcGUbLZz4P1vVFHuT/mm9PSE5u/6Z9iycqpejySU+iM8Yg56aGuwKRtXGye3urH7k+4rOjUgLdbrOTp5VfYEoVlQmCF8CuuUs91hRhM2cIQBTBNal9Zr7vcBhzyN268HqtUulzHsj3yevwhX3sZOXCXYBDOXAQdHvRS8IfQm4TegXkw6P4XvDeM9U8wFyQo+2BglRXBCigG/VdsCciGvk0EWi/4TyTAQ+cHf+WTy1Mklq+ISew3KUBEX24VJSjVJIyBjeMXTAsFOxdnuAxJpINBxUlA0AoUKswkdDasK6jySOpjVkmthtnifYBkPhUU0FHBKll8XLvELh3oLTyd79+JpSuGGjEGix55KMiAwsE6a5f7gGX+z+vkZ2MS3ZSFQZETZMZLr82KSpyKv4nISCtvrjG4x2pcz0zASZw65VleXNq6bmtmbg6gTRDv59OoJ/wH3YYp/XhSM7Z6LZgQ5DWEPabQHexNPACdDw2Cn0VParC7OP+d/aKQb2ZszSz4xNPr3NEV+SEJRlvWIIhhLWMuGk+dCwVRywcsKbxfzSJTHKYCkwcJ9mC7ZmdMJz691rHn81dzgfJwtyUrk98PQ4t6YdD4JIEBA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(7916004)(4636009)(366004)(44832011)(54906003)(186003)(2906002)(38070700005)(6636002)(122000001)(26005)(86362001)(38100700002)(7416002)(66476007)(66556008)(64756008)(66446008)(91956017)(76116006)(4326008)(66946007)(71200400001)(5660300002)(8936002)(6512007)(6506007)(8676002)(9686003)(316002)(33716001)(508600001)(6486002)(83380400001)(1076003)(6862004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?N8b9dXswWz7QD1ZNACeN1w5jGxQG8Vo8CPyk88MThe1D93E73ktM2yWidakm?= =?us-ascii?Q?98UaVUfT+4hGv+fPKIlqr55H593GivacLrR8JdcVk4kqS1X7/cwZrlzNBN3F?= =?us-ascii?Q?aKI4o5Vf/khfcVWsRUnCRfp0aew40eUK/KAXEcZKZe4KRWfviwWzl7xSWhxx?= =?us-ascii?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gQaFIM0t3bcQF4XO?= =?us-ascii?Q?k5PnftDeNf1YYbceXS+RBxC1UBe7MTP5GEwGcx1uG0RFJ/B4G1l8yIwp3QSE?= =?us-ascii?Q?zFamiH3ct+0MWqD14NJGZdRqSuENAUEfGCDVpLCh40VkVpq+is7fUFcHK0Yg?= =?us-ascii?Q?iPnVkAyjC698Y2SWpSvll45ZZ4XaqB518VayDcF3ebeE8scEtHzcBUJUsbmu?= =?us-ascii?Q?JXK9qxG21R3kd1dvZPheFto2q2he3yNzg5SoUHqMzT8Z1HI9ilaTOQkLFiJT?= =?us-ascii?Q?O2nWZE4fqAGYy76Y3xfmnhGw?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ad77a97-9411-4dd0-c111-08d9805a71e2 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2021 19:26:59.4944 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zHCGNlCc3hVzTMK/dfkU69+AhY7p27DatjAw7A02BscocurMKLGtr9k2sPY/C/Iq5AafJP+NvEt3lPWlLSU7qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2863 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210925_122713_317026_35A4C493 X-CRM114-Status: GOOD ( 27.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 24, 2021 at 05:52:20PM +0800, Xiaoliang Yang wrote: > From: Vladimir Oltean > > ocelot_mact_learn_streamdata() can be used in VSC9959 to overwrite an > FDB entry with stream data. The stream data includes SFID and SSID which > can be used for PSFP and FRER set. > > ocelot_mact_lookup() can be used to check if the given {DMAC, VID} FDB > entry is exist, and also can retrieve the DEST_IDX and entry type for > the FDB entry. > > Signed-off-by: Vladimir Oltean > Signed-off-by: Xiaoliang Yang This is most certainly not my patch either, so you can drop my name from it. > --- > drivers/net/ethernet/mscc/ocelot.c | 50 ++++++++++++++++++++++++++++++ > include/soc/mscc/ocelot.h | 5 +++ > 2 files changed, 55 insertions(+) > > diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c > index 35006b0fb963..dc65247b91be 100644 > --- a/drivers/net/ethernet/mscc/ocelot.c > +++ b/drivers/net/ethernet/mscc/ocelot.c > @@ -114,6 +114,56 @@ int ocelot_mact_forget(struct ocelot *ocelot, > } > EXPORT_SYMBOL(ocelot_mact_forget); > > +int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx, > + struct ocelot_mact_entry *entry) I think the arguments of this function can be improved. Currently, "entry" is an inout argument: entry->mac and entry->vid are input, and entry->type is output. I think it would be better if the argument list looked like this: int ocelot_mact_lookup(struct ocelot *ocelot, const unsigned char *addr, u16 vid, enum macaccess_entry_type *type, int *dst_idx) I think it's clearer this way which arguments are input and which are output. Additionally, you can stop exporting struct ocelot_mact_entry, if this is the only reason you needed it. > +{ > + int val; > + > + mutex_lock(&ocelot->mact_lock); > + > + ocelot_mact_select(ocelot, entry->mac, entry->vid); > + > + /* Issue a read command with MACACCESS_VALID=1. */ > + ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID | > + ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_READ), > + ANA_TABLES_MACACCESS); > + > + if (ocelot_mact_wait_for_completion(ocelot)) { > + mutex_unlock(&ocelot->mact_lock); > + return -ETIMEDOUT; > + } > + > + /* Read back the entry flags */ > + val = ocelot_read(ocelot, ANA_TABLES_MACACCESS); > + > + mutex_unlock(&ocelot->mact_lock); > + > + if (!(val & ANA_TABLES_MACACCESS_VALID)) > + return -ENOENT; > + > + *dst_idx = ANA_TABLES_MACACCESS_DEST_IDX_X(val); > + entry->type = ANA_TABLES_MACACCESS_ENTRYTYPE_X(val); > + > + return 0; > +} > +EXPORT_SYMBOL(ocelot_mact_lookup); > + > +int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx, > + struct ocelot_mact_entry *entry, u32 data) It would be nice if ocelot_mact_learn_streamdata would follow the basic prototype of ocelot_mact_learn: int ocelot_mact_learn(struct ocelot *ocelot, int port, const unsigned char mac[ETH_ALEN], unsigned int vid, enum macaccess_entry_type type) just with the extra STREAMDATA argument at the end. Also, could we format the STREAMDATA nicer than a raw u32? > +{ > + int ret; > + > + mutex_lock(&ocelot->mact_lock); > + ocelot_write(ocelot, data, ANA_TABLES_STREAMDATA); > + mutex_unlock(&ocelot->mact_lock); > + > + ret = ocelot_mact_learn(ocelot, dst_idx, entry->mac, entry->vid, > + entry->type); Hm, if you temporarily drop the lock just for ocelot_mact_learn to take it again, you allow somebody else to sneak in and learn another MAC table entry, and the STREAMDATA will get associated with that other guy and not with you, no? > + > + return ret; > +} > +EXPORT_SYMBOL(ocelot_mact_learn_streamdata); > + > static void ocelot_mact_init(struct ocelot *ocelot) > { > /* Configure the learning mode entries attributes: > diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h > index e6773f4d09ce..455293652257 100644 > --- a/include/soc/mscc/ocelot.h > +++ b/include/soc/mscc/ocelot.h > @@ -926,6 +926,11 @@ void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port, > bool tx_pause, bool rx_pause, > unsigned long quirks); > > +int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx, > + struct ocelot_mact_entry *entry); > +int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx, > + struct ocelot_mact_entry *entry, u32 data); > + > #if IS_ENABLED(CONFIG_BRIDGE_MRP) > int ocelot_mrp_add(struct ocelot *ocelot, int port, > const struct switchdev_obj_mrp *mrp); > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel