Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1040947rdf; Sat, 4 Nov 2023 04:35:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUQ2gTmN9/AL9PnoIixbKx6wazulMHFZddGeiC9Jm7Jrq0FHmaxQK3Orf/WAIOhVkuoK1D X-Received: by 2002:a17:90b:3d1:b0:27f:df1e:199e with SMTP id go17-20020a17090b03d100b0027fdf1e199emr25146383pjb.28.1699097735067; Sat, 04 Nov 2023 04:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699097735; cv=none; d=google.com; s=arc-20160816; b=03LNYX/UC2wI2Qlz0TES41GA0tlL95YQkU9ldOM1QA70GKh5jbPAmrSFqqqsxf2ZYY DZKBUc6lEO72VT0Zdg8vZ2feT3wkA8z0G7+BtR6RuYVkaQigz5d7IG+bmY41blR2EIq8 LrN8VeCIyYJLRTWeZm12L7M9wJrbUfCVg4PA4wZMMJP2VtYz+q7fee6DQVMUUF4c9BWI HpcOrMqDDBKGfq60Q3SPO8011PQLm9VBS5A7UpwSRXLIiV+kXKfOx/otQqLVgHAuleJZ BHdVH0nYCZqhpi26yQf85UC6RtHdwyizyjOnj1XyFc/zLOWgFxFL4gbBusLOLFw3T3bi on1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pBFiRyyVLBwODhyZWi8+s/j30jLtPF907TxY4rXPKlk=; fh=31Q5E0xZEnG9WsKra3ZUPypH1wG04NpoA4L44RLWFnc=; b=rXUFr7XIIPwkPimw8kHTIfimFgd98nbhfslOWtHj3NMuGciPr1OLIO9WnXBps8v3w0 arpPEA862hhtBxwHb1lyCkCrX60tDW1zhcdwX2nTsBh61cQNd2TqnvsC8svJBJQMjYpo FDDW3+FXoXNWMzMXbiE4vkkzaiToFtlVmClQyzKUO21LLm6LZBpyU90VkF8CAYF4QzXR vSK4/UHRJJ4bjcP1AoiwTBHY9doYNEactWUMNpF9MefxlRtAQhI/XQJnPFz6/LHSx9fW widNVYgLJm3DrkgMKV/CHVc1CoStbt6dT7Ql0JtNWW1+EkyzYMrmOnvj5KstQnEhr0pT 8xaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F81P/3b6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ot3-20020a17090b3b4300b0026b365096e5si3879421pjb.53.2023.11.04.04.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 04:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F81P/3b6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 03FA78047558; Sat, 4 Nov 2023 04:35:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231945AbjKDLfd (ORCPT + 99 others); Sat, 4 Nov 2023 07:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjKDLfc (ORCPT ); Sat, 4 Nov 2023 07:35:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF4FDD49 for ; Sat, 4 Nov 2023 04:35:27 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FD4FC433C8; Sat, 4 Nov 2023 11:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699097727; bh=eQe1wFKxq3ZqObZy6vRwp3gsb3y+Y6bu7pHdSAo8SKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F81P/3b6o/poheCB9O8X8dq9m/r4k6OKV33/JSc/hoIHLNId4FeYJIoIR/O/bghTJ wdaguamX+dW5SZynhF9CZ3yH9joJNEXznIAi1ep7EnYx2i++yLG9f1XeDOIecntp3E lqhtLpiJE1US6hx5ejpi1bgxWEdFFvPL/b4T98kpkn1cw2MSlT+a4GEDv0aM8mJ09Z Bn2IT7V4BEYdTjI9mG6aPn5MzrHdVbHgIxW5w4mcG9O8FVnR/PvhUeMCDSdgFj21To z1X9qs/8So1bYiyJ0r4NMKWz7sPNotpu70PvlwrBv49HsTHWQiVc1agxswAUpLO5MC LpjCqZahpUGLg== Date: Sat, 4 Nov 2023 11:35:06 +0000 From: Simon Horman To: "Radu Pirea (NXP OSS)" Cc: sd@queasysnail.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, sebastian.tobuschat@oss.nxp.com Subject: Re: [PATCH net-next v8 5/7] net: phy: nxp-c45-tja11xx: add MACsec support Message-ID: <20231104113506.GA891380@kernel.org> References: <20231023094327.565297-1-radu-nicolae.pirea@oss.nxp.com> <20231023094327.565297-6-radu-nicolae.pirea@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231023094327.565297-6-radu-nicolae.pirea@oss.nxp.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 04:35:34 -0700 (PDT) On Mon, Oct 23, 2023 at 12:43:25PM +0300, Radu Pirea (NXP OSS) wrote: > Add MACsec support. > The MACsec block has four TX SCs and four RX SCs. The driver supports up > to four SecY. Each SecY with one TX SC and one RX SC. > The RX SCs can have two keys, key A and key B, written in hardware and > enabled at the same time. > The TX SCs can have two keys written in hardware, but only one can be > active at a given time. > On TX, the SC is selected using the MAC source address. Due of this > selection mechanism, each offloaded netdev must have a unique MAC > address. > On RX, the SC is selected by SCI(found in SecTAG or calculated using MAC > SA), or using RX SC 0 as implicit. > > Signed-off-by: Radu Pirea (NXP OSS) ... > +void nxp_c45_handle_macsec_interrupt(struct phy_device *phydev, > + irqreturn_t *ret) > +{ > + struct nxp_c45_phy *priv = phydev->priv; > + struct nxp_c45_secy *pos, *tmp; > + struct nxp_c45_sa *sa; > + u8 encoding_sa; > + int secy_id; > + u32 reg = 0; > + > + if (!priv->macsec) > + return; > + > + do { > + nxp_c45_macsec_read(phydev, MACSEC_EVR, ®); > + if (!reg) > + return; > + > + secy_id = MACSEC_REG_SIZE - ffs(reg); > + list_for_each_entry_safe(pos, tmp, &priv->macsec->secy_list, > + list) > + if (pos->secy_id == secy_id) > + break; > + > + encoding_sa = pos->secy->tx_sc.encoding_sa; Hi Radu, I'm unsure if this can happen, but my understanding is that if priv->macsec->secy_list is empty then pos will be uninitialised here. Flagged by Coccinelle. > + phydev_dbg(phydev, "pn_wrapped: TX SC %d, encoding_sa %u\n", > + pos->secy_id, encoding_sa); > + > + sa = nxp_c45_find_sa(&pos->sa_list, TX_SA, encoding_sa); > + if (!IS_ERR(sa)) > + macsec_pn_wrapped(pos->secy, sa->sa); > + else > + WARN_ON(1); > + > + nxp_c45_macsec_write(phydev, MACSEC_EVR, > + TX_SC_BIT(pos->secy_id)); > + *ret = IRQ_HANDLED; > + } while (reg); > +} ...