From patchwork Tue May 9 14:35:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13235639 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 6C2F0AD44 for ; Tue, 9 May 2023 11:35:22 +0000 (UTC) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DDC42D62; Tue, 9 May 2023 04:35:20 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f139de8cefso33274559e87.0; Tue, 09 May 2023 04:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683632118; x=1686224118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JEf8nW/e5rX1lrg2FM6+u2SZlAqTzqdeg72ZyL+zfRU=; b=DBoK7x1nOErHLKNeDarD+nJ7xAfoTVKzzzuvV1+0EbaXnT+NGaI9yz1CqpLTLvlkxm oSWE5X4e8uxiEGBIr+IzKysYKjXZQ312NPrRhjhNmUngxnuVTVxXKll5VG/qmg/Sgrhy inlNsCjDZJH28ohfRxgnqdan/4ecqPNd37GN3bd2IhmfrPRKcdyzLpkX8iM5DkcWIzMl T2AAxrNOH7fqdgxZrSiZWOx+1beHKeCywGAZ67WmNmOx/due+1rOadlAn+HbVCGaytkU f09hDEuCgfz2tHeHpd4+DWuYe/wrtwzNrR2CSsbgZk2vx1G9AUvbR0EDm+MWfaoZEeV3 6WXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683632118; x=1686224118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JEf8nW/e5rX1lrg2FM6+u2SZlAqTzqdeg72ZyL+zfRU=; b=SYIpi8UD5dZKcP0gqvWz31Gq1InQq2T+wbZb65iS9JuYMLmvWAqHNJQ5HWagL+ZUVc YTtcekY0qogJmdB9IVSR6fngdzwh17gnF27Y2IvOjFHziC8t0y6EBU/fHTZ4tfmL33xd 7lVPRI4okQJQVRY6snMEV91/fvAV0DUm8q/5yC3rIpGef2wrrYF0rGNS5dJ2MNpezt2V pMZa+b0iRuQ49QsgbO3TjYQspqEsDyxjHiY1xU7/rQP0QB7zaXVzjRulPvSevNWiZ4sc 7nlYNxuBx/neVqGT+xl4bTuyOhBcEow0p0EW3RHjz67pmv9njIgXzmyuxpJdsrC/onlq m+Mg== X-Gm-Message-State: AC+VfDy7xes0b/sgopJ7ysdyoQHAjXgo5qtNUBXv5AfnqHpA1YtoODsQ kXkot0bxDfr5QsTTW8/ieUA= X-Google-Smtp-Source: ACHHUZ5P6iPUUpdtAE+teUteA2tmyf8nbg5M4SKeRktLOJxdu7PzVPHjY547loWAYyrHE3ux5CGtGg== X-Received: by 2002:ac2:5d6b:0:b0:4ee:fdd8:a536 with SMTP id h11-20020ac25d6b000000b004eefdd8a536mr684045lft.8.1683632118467; Tue, 09 May 2023 04:35:18 -0700 (PDT) Received: from localhost.localdomain (93-80-66-133.broadband.corbina.ru. [93.80.66.133]) by smtp.googlemail.com with ESMTPSA id k16-20020ac24570000000b004f25ccac240sm108940lfm.74.2023.05.09.04.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 04:35:17 -0700 (PDT) From: Ivan Mikhaylov To: Samuel Mendoza-Jonas , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Ivan Mikhaylov Subject: [PATCH v2 1/5] net/ncsi: make one oem_gma function for all mfr id Date: Tue, 9 May 2023 14:35:00 +0000 Message-Id: <20230509143504.30382-2-fr0st61te@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509143504.30382-1-fr0st61te@gmail.com> References: <20230509143504.30382-1-fr0st61te@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org Make the one Get Mac Address function for all manufacturers and change this call in handlers accordingly. Signed-off-by: Ivan Mikhaylov Reviewed-by: Simon Horman --- net/ncsi/ncsi-rsp.c | 88 ++++++++++----------------------------------- 1 file changed, 19 insertions(+), 69 deletions(-) diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 6447a09932f5..91c42253a711 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -611,14 +611,15 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr) return 0; } -/* Response handler for Mellanox command Get Mac Address */ -static int ncsi_rsp_handler_oem_mlx_gma(struct ncsi_request *nr) +/* Response handler for Get Mac Address command */ +static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) { struct ncsi_dev_priv *ndp = nr->ndp; struct net_device *ndev = ndp->ndev.dev; const struct net_device_ops *ops = ndev->netdev_ops; struct ncsi_rsp_oem_pkt *rsp; struct sockaddr saddr; + u32 mac_addr_off = 0; int ret = 0; /* Get the response header */ @@ -626,7 +627,19 @@ static int ncsi_rsp_handler_oem_mlx_gma(struct ncsi_request *nr) saddr.sa_family = ndev->type; ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; - memcpy(saddr.sa_data, &rsp->data[MLX_MAC_ADDR_OFFSET], ETH_ALEN); + if (mfr_id == NCSI_OEM_MFR_BCM_ID) + mac_addr_off = BCM_MAC_ADDR_OFFSET; + else if (mfr_id == NCSI_OEM_MFR_MLX_ID) + mac_addr_off = MLX_MAC_ADDR_OFFSET; + else if (mfr_id == NCSI_OEM_MFR_INTEL_ID) + mac_addr_off = INTEL_MAC_ADDR_OFFSET; + + memcpy(saddr.sa_data, &rsp->data[mac_addr_off], ETH_ALEN); + if (mfr_id == NCSI_OEM_MFR_BCM_ID || mfr_id == NCSI_OEM_MFR_INTEL_ID) + eth_addr_inc((u8 *)saddr.sa_data); + if (!is_valid_ether_addr((const u8 *)saddr.sa_data)) + return -ENXIO; + /* Set the flag for GMA command which should only be called once */ ndp->gma_flag = 1; @@ -649,41 +662,10 @@ static int ncsi_rsp_handler_oem_mlx(struct ncsi_request *nr) if (mlx->cmd == NCSI_OEM_MLX_CMD_GMA && mlx->param == NCSI_OEM_MLX_CMD_GMA_PARAM) - return ncsi_rsp_handler_oem_mlx_gma(nr); + return ncsi_rsp_handler_oem_gma(nr, NCSI_OEM_MFR_MLX_ID); return 0; } -/* Response handler for Broadcom command Get Mac Address */ -static int ncsi_rsp_handler_oem_bcm_gma(struct ncsi_request *nr) -{ - struct ncsi_dev_priv *ndp = nr->ndp; - struct net_device *ndev = ndp->ndev.dev; - const struct net_device_ops *ops = ndev->netdev_ops; - struct ncsi_rsp_oem_pkt *rsp; - struct sockaddr saddr; - int ret = 0; - - /* Get the response header */ - rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); - - saddr.sa_family = ndev->type; - ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; - memcpy(saddr.sa_data, &rsp->data[BCM_MAC_ADDR_OFFSET], ETH_ALEN); - /* Increase mac address by 1 for BMC's address */ - eth_addr_inc((u8 *)saddr.sa_data); - if (!is_valid_ether_addr((const u8 *)saddr.sa_data)) - return -ENXIO; - - /* Set the flag for GMA command which should only be called once */ - ndp->gma_flag = 1; - - ret = ops->ndo_set_mac_address(ndev, &saddr); - if (ret < 0) - netdev_warn(ndev, "NCSI: 'Writing mac address to device failed\n"); - - return ret; -} - /* Response handler for Broadcom card */ static int ncsi_rsp_handler_oem_bcm(struct ncsi_request *nr) { @@ -695,42 +677,10 @@ static int ncsi_rsp_handler_oem_bcm(struct ncsi_request *nr) bcm = (struct ncsi_rsp_oem_bcm_pkt *)(rsp->data); if (bcm->type == NCSI_OEM_BCM_CMD_GMA) - return ncsi_rsp_handler_oem_bcm_gma(nr); + return ncsi_rsp_handler_oem_gma(nr, NCSI_OEM_MFR_BCM_ID); return 0; } -/* Response handler for Intel command Get Mac Address */ -static int ncsi_rsp_handler_oem_intel_gma(struct ncsi_request *nr) -{ - struct ncsi_dev_priv *ndp = nr->ndp; - struct net_device *ndev = ndp->ndev.dev; - const struct net_device_ops *ops = ndev->netdev_ops; - struct ncsi_rsp_oem_pkt *rsp; - struct sockaddr saddr; - int ret = 0; - - /* Get the response header */ - rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp); - - saddr.sa_family = ndev->type; - ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; - memcpy(saddr.sa_data, &rsp->data[INTEL_MAC_ADDR_OFFSET], ETH_ALEN); - /* Increase mac address by 1 for BMC's address */ - eth_addr_inc((u8 *)saddr.sa_data); - if (!is_valid_ether_addr((const u8 *)saddr.sa_data)) - return -ENXIO; - - /* Set the flag for GMA command which should only be called once */ - ndp->gma_flag = 1; - - ret = ops->ndo_set_mac_address(ndev, &saddr); - if (ret < 0) - netdev_warn(ndev, - "NCSI: 'Writing mac address to device failed\n"); - - return ret; -} - /* Response handler for Intel card */ static int ncsi_rsp_handler_oem_intel(struct ncsi_request *nr) { @@ -742,7 +692,7 @@ static int ncsi_rsp_handler_oem_intel(struct ncsi_request *nr) intel = (struct ncsi_rsp_oem_intel_pkt *)(rsp->data); if (intel->cmd == NCSI_OEM_INTEL_CMD_GMA) - return ncsi_rsp_handler_oem_intel_gma(nr); + return ncsi_rsp_handler_oem_gma(nr, NCSI_OEM_MFR_INTEL_ID); return 0; } From patchwork Tue May 9 14:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13235640 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 4234A17ADD for ; Tue, 9 May 2023 11:35:23 +0000 (UTC) Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF9330D2; Tue, 9 May 2023 04:35:21 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4f122ff663eso6445703e87.2; Tue, 09 May 2023 04:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683632119; x=1686224119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rbkI5NmwcrpI7Tje+0YGtVpuM20p51DDt0R9mEUMkGo=; b=iw0rSsRolEB5fcb1p+xNJhOEdDLAJa+ATnHCa0O+77TWWDGr1x5ufaNs08BChkoQ7K udgVvcX8F+R0B4ebCJ7cW/focSGQS71wUJnkipeT1bX/Dmec/pE8n0UazwgSEHM9ZRif omj3c0fwoBOb5oGvNVMACVBpWIpW8j29jEsHka/8ortL4cXCwl7tMrKTbVfE6brnBu4L 2AVxfipHGS57Q9OXuuUOxMIbmiMiB8c0zGTtsvi1CQTxVdNjaaWn0mU9LaGURYcMa/yA EK25ji2YBaZSGG27mArhQGyHIxXX0yl53DIFefFZee1flg6Rp9MMHLKUwiWBW8OczDvN THTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683632119; x=1686224119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rbkI5NmwcrpI7Tje+0YGtVpuM20p51DDt0R9mEUMkGo=; b=ejF7s/AZQV2ROIT6D/3l8uI8UzbcEv9J5zZCyOMNbghpw6Bbr46ju84aExLzfVS9a8 /2o5fAY/+4CseOwIEGNaLdiqXUzkcXYoMp1pN/zOMsJiajQP2n//ERddCejR0myBJKyg r7J1UW9r+89Bul/vr7hscVDs7USRaKefkjooBpzplRI2Gp/W5fxhWXRvBW+6Etn0eDe2 jvZJim+wMuysV0agSrfx8HbKfC8b3ePKbW1uipT+too2i3cMoLDQwSpEtmHdiLLkBjgc n88swoZrqn9YEjRk6h6bL57Y852UI7V1+42rzFVZYhPKwUTIsDIkv2Krguif5tkbwwGD n3Kw== X-Gm-Message-State: AC+VfDw0J6N2VoOzWog3aZWNvP/YSd9Iwl37BzuXhtwwnn6CqDc7bzn+ kyiOg9l4dWb/gcrGD3971hQ= X-Google-Smtp-Source: ACHHUZ7SGF4LClRs/QE8T9m+zaDb2DYiF6XKALpXn5c53WZ7SBsib2YNkQAZnuDJ6RG/0PZqo56rdg== X-Received: by 2002:ac2:562f:0:b0:4f1:3d6c:d89b with SMTP id b15-20020ac2562f000000b004f13d6cd89bmr607190lff.42.1683632119511; Tue, 09 May 2023 04:35:19 -0700 (PDT) Received: from localhost.localdomain (93-80-66-133.broadband.corbina.ru. [93.80.66.133]) by smtp.googlemail.com with ESMTPSA id k16-20020ac24570000000b004f25ccac240sm108940lfm.74.2023.05.09.04.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 04:35:18 -0700 (PDT) From: Ivan Mikhaylov To: Samuel Mendoza-Jonas , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Ivan Mikhaylov , Paul Fertser Subject: [PATCH v2 2/5] net/ncsi: change from ndo_set_mac_address to dev_set_mac_address Date: Tue, 9 May 2023 14:35:01 +0000 Message-Id: <20230509143504.30382-3-fr0st61te@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509143504.30382-1-fr0st61te@gmail.com> References: <20230509143504.30382-1-fr0st61te@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org Change ndo_set_mac_address to dev_set_mac_address because dev_set_mac_address provides a way to notify network layer about MAC change. In other case, services may not aware about MAC change and keep using old one which set from network adapter driver. As example, DHCP client from systemd do not update MAC address without notification from net subsystem which leads to the problem with acquiring the right address from DHCP server. Signed-off-by: Paul Fertser Signed-off-by: Ivan Mikhaylov --- net/ncsi/ncsi-rsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 91c42253a711..069c2659074b 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -616,7 +616,6 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) { struct ncsi_dev_priv *ndp = nr->ndp; struct net_device *ndev = ndp->ndev.dev; - const struct net_device_ops *ops = ndev->netdev_ops; struct ncsi_rsp_oem_pkt *rsp; struct sockaddr saddr; u32 mac_addr_off = 0; @@ -643,7 +642,9 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) /* Set the flag for GMA command which should only be called once */ ndp->gma_flag = 1; - ret = ops->ndo_set_mac_address(ndev, &saddr); + rtnl_lock(); + ret = dev_set_mac_address(ndev, &saddr, NULL); + rtnl_unlock(); if (ret < 0) netdev_warn(ndev, "NCSI: 'Writing mac address to device failed\n"); From patchwork Tue May 9 14:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13235641 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 52033182A9 for ; Tue, 9 May 2023 11:35:24 +0000 (UTC) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 110A12D58; Tue, 9 May 2023 04:35:22 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4efe8b3f3f7so6555112e87.2; Tue, 09 May 2023 04:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683632120; x=1686224120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aQ9PB/UjgQdEomLsQFjCrSpNBCkBCgqrAFyhnpB0P5Q=; b=AGmJEnX5lM99SSQkFuTItq4ndHX2KRpXyqZvV0gG2r8ACzzjDEUaMa9gGMcROf1TdF FwUqjU7T0m6o6qMrqVrDjrvmtotNEkJRFsTKldLFyJHw8y20SkkoNZNmttmBkkeVC534 MYFi15xzLOwd/yuV0Moral/BgTbCAWCKRqFsWSzog/WqeGJzorm4TX1WtfL5sij1fdT8 bp+mpdyipj2Kdm75szKLNI80mOz8zdf3qcOphWXTlTXLlIUNBzFe7U2g5LVkvYWf3bhO uph4mNsQYNl+bylVL0YS+1l+23S7iCUqBHO/dHGLoTnhtzGFm8Kn9CmyakMjHwGo3Pr2 7q0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683632120; x=1686224120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aQ9PB/UjgQdEomLsQFjCrSpNBCkBCgqrAFyhnpB0P5Q=; b=FyVTtPi7rpHlEA2E3SvIS2ALUb9zPIEkxmp9SemYdGAxWrAVQqWlQxaUkxs4edXutB wE8wSNOXVuu7s4cEFqS+yQqVHGU9pUTexyWQCT1onXSadgWeW09s/36LB5K6X6ZwgS+u QWwqnHvgGylfahvaH2WnN7Sx6w/n51OrSU47GAzbarDLTVTg4bxMUJavd/RlVTaeGnXC XXNWpqcvMPACaO5n9PuBmE0Kfxs6El8MzcmTRlz7XC2OChfrX+N2VHtN9lnuzrLjWyCM 8gHD1D3GEI7qOtybdMpPQNk74vKHpet5/iXq/XndkULK9qotmToOEkqRSf1On8vk3946 Vdng== X-Gm-Message-State: AC+VfDxLtHTKiGFKKYOTxQWGETDKHSr/hsO2XI3bktYXJMq0SZFbLHeU qQu2ewGIo6/0fH5CBIGIitc= X-Google-Smtp-Source: ACHHUZ6GvZGEid83w6782Tu4dK7RhRUtad1gNRgpAbl5QMHkN490GGttEB3yPd9qZJ+bmNOmx9T/JA== X-Received: by 2002:ac2:5638:0:b0:4f1:26f5:7814 with SMTP id b24-20020ac25638000000b004f126f57814mr649736lff.20.1683632120413; Tue, 09 May 2023 04:35:20 -0700 (PDT) Received: from localhost.localdomain (93-80-66-133.broadband.corbina.ru. [93.80.66.133]) by smtp.googlemail.com with ESMTPSA id k16-20020ac24570000000b004f25ccac240sm108940lfm.74.2023.05.09.04.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 04:35:20 -0700 (PDT) From: Ivan Mikhaylov To: Samuel Mendoza-Jonas , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Ivan Mikhaylov , Paul Fertser Subject: [PATCH v2 3/5] dt-bindings: net: add mac-address-increment option Date: Tue, 9 May 2023 14:35:02 +0000 Message-Id: <20230509143504.30382-4-fr0st61te@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509143504.30382-1-fr0st61te@gmail.com> References: <20230509143504.30382-1-fr0st61te@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org Add the mac-address-increment option for specify MAC address taken by any other sources. Signed-off-by: Paul Fertser Signed-off-by: Ivan Mikhaylov --- .../devicetree/bindings/net/ethernet-controller.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index 00be387984ac..6900098c5105 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -34,6 +34,14 @@ properties: minItems: 6 maxItems: 6 + mac-address-increment: + $ref: /schemas/types.yaml#/definitions/int32 + description: + Specifies the MAC address increment to be added to the MAC address. + Should be used in cases when there is a need to use MAC address + different from one obtained by any other level, like u-boot or the + NC-SI stack. + max-frame-size: $ref: /schemas/types.yaml#/definitions/uint32 description: From patchwork Tue May 9 14:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13235642 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 5B98A182A9 for ; Tue, 9 May 2023 11:35:25 +0000 (UTC) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184922D62; Tue, 9 May 2023 04:35:23 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f24cfb8539so2872364e87.3; Tue, 09 May 2023 04:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683632121; x=1686224121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8zWM9Ku4QEF1MXGuje7rt5LFZjeiu0mnfAywbxjklTg=; b=GsClSg+96jqtWjYLPTKM5pAJI4Eo2Ah8uaXlBAjQknewgiD5RpDgLbDOeUHrrdfrQj WuJ0Y6pxTynTReP5smOZrhhjFAN7AVjy0gOR/IKJNhvNZClw6ASSuIfokJ9+WvofxOfM 9aiSdbQK+suvq1C0Pe2xoy/YOi1G5c2WKReuwgQnwIZzkeM7IQe3cyRksKtFDaOGZUtP 8DIdgFxhvFepNFy7jRPo+Ql7m1jw76sq13DjFpna9nCCeyHhYRiio1PUxHCQV5R1mK0y BKnop1iVJlY7vVgXY4M91QeAEczd+kz22dym4iKCDv7/g5OAC4QJ0cZ1hyOiQUyv/PPn emdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683632121; x=1686224121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8zWM9Ku4QEF1MXGuje7rt5LFZjeiu0mnfAywbxjklTg=; b=RMKOH9b99MAbRuR1Jtt11HX7oB1/jl14YpVE610gw2hHDWqic3havwTbznUiO4Qkum xepGieogzkqQuaDwBj+j7Kc4vp1Bi9ffy/39mktLhx1QgYN9voKWd/ly7cQKtyVLQUu4 iR7kn0ivenuA6c0p5rXxvwh2AEovLMjIXr0M5EgfXYGWFCBmZpUmeE496QSlt99vsrSF 1OJZPiJaAgzoE3mndM7qdFDUEiGWQ5B6xuSWubRPGrx59tYdWl+8onON0K0z2F8ETiQn LEbmIhvqZhWB+5rnhWXKtfzc1omCSEAwVChgDIUcz3KS19f/H9l2JIoQFzQOazH189SO Rnrw== X-Gm-Message-State: AC+VfDw9jZSvHMFDiyCuKj3OH2IvIAZw5xypEeCKLS6rWP8quHYQUTWl HcWdG7T/OGjJ+n/gr1JWRG8= X-Google-Smtp-Source: ACHHUZ4rSmlvz0jORkDZiqRrHk7JyLuRrDC5VraFbgQQXsHmS+H1SxrFJ8w8Mx2ICmrN1/BOlrRVRQ== X-Received: by 2002:ac2:46f8:0:b0:4ef:fe49:e14f with SMTP id q24-20020ac246f8000000b004effe49e14fmr647454lfo.20.1683632121311; Tue, 09 May 2023 04:35:21 -0700 (PDT) Received: from localhost.localdomain (93-80-66-133.broadband.corbina.ru. [93.80.66.133]) by smtp.googlemail.com with ESMTPSA id k16-20020ac24570000000b004f25ccac240sm108940lfm.74.2023.05.09.04.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 04:35:21 -0700 (PDT) From: Ivan Mikhaylov To: Samuel Mendoza-Jonas , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Ivan Mikhaylov Subject: [PATCH v2 4/5] net/ncsi: add shift MAC address property Date: Tue, 9 May 2023 14:35:03 +0000 Message-Id: <20230509143504.30382-5-fr0st61te@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509143504.30382-1-fr0st61te@gmail.com> References: <20230509143504.30382-1-fr0st61te@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org Add the shift MAC address property for GMA command which provides which shift should be used but keep old one values for backward compatability. Signed-off-by: Ivan Mikhaylov --- net/ncsi/ncsi-rsp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 069c2659074b..1f108db34d85 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include @@ -616,9 +618,12 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) { struct ncsi_dev_priv *ndp = nr->ndp; struct net_device *ndev = ndp->ndev.dev; + struct platform_device *pdev; struct ncsi_rsp_oem_pkt *rsp; struct sockaddr saddr; u32 mac_addr_off = 0; + s32 shift_mac_addr = 0; + u64 mac_addr; int ret = 0; /* Get the response header */ @@ -635,7 +640,17 @@ static int ncsi_rsp_handler_oem_gma(struct ncsi_request *nr, int mfr_id) memcpy(saddr.sa_data, &rsp->data[mac_addr_off], ETH_ALEN); if (mfr_id == NCSI_OEM_MFR_BCM_ID || mfr_id == NCSI_OEM_MFR_INTEL_ID) - eth_addr_inc((u8 *)saddr.sa_data); + shift_mac_addr = 1; + + pdev = to_platform_device(ndev->dev.parent); + if (pdev) + of_property_read_s32(pdev->dev.of_node, + "mac-address-increment", &shift_mac_addr); + + /* Increase mac address by shift value for BMC's address */ + mac_addr = ether_addr_to_u64((u8 *)saddr.sa_data); + mac_addr += shift_mac_addr; + u64_to_ether_addr(mac_addr, (u8 *)saddr.sa_data); if (!is_valid_ether_addr((const u8 *)saddr.sa_data)) return -ENXIO; From patchwork Tue May 9 14:35:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13235643 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 1ED73182A9 for ; Tue, 9 May 2023 11:35:26 +0000 (UTC) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C82CF30FA; Tue, 9 May 2023 04:35:23 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f1411e8111so6438965e87.1; Tue, 09 May 2023 04:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683632122; x=1686224122; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+QQeh9YjZzNjrXQibFSAmN6bJH27K6sErXcLxHfNpn8=; b=Sam+crretoYBxWHA4qS3k5/sYy/9YNnNDeOcT/ax6idvKykJaCktFYNZ0iU6e8debI B8DvJGdp1lL3Q7x5zbpU5gXoSw53k9Ch9CLd1ox4Z0XpstyGRuMY0jd47E1L/eoeTtLi hyCkyvBViRBW90AOQReNZeqrscn3rogJXPMFlMm3HeRi7zJGYsvW5u0Dw7CtEC/mJGve RS0Mg6lh3GQw0reca5/4SrH/9HdIWYtkje+PabbVny0Z158fzPPjMkcwOHo3XQEG2cVA SjPjIPX5M11qNKaKPNIeqAQOvqo0H0DPctFCbD2iK5JPG0LYGFH5dl9SQTIcaJra+uYW qqSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683632122; x=1686224122; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QQeh9YjZzNjrXQibFSAmN6bJH27K6sErXcLxHfNpn8=; b=ijy5HsnaEpqmxkn3Dj9gujvKZgRgJgyaiPRqb6nqR3F4Uvr0AFvtVnDjx6hfMy4D4Q i8z/03YjsAxufRvHk+N5n0FR8YcbZ57s+TMsmdYC9pAnOQi3CPVEO8MYnruXlpWzyVGY B7miBDL1r2fgHrw3z4Xw8jEd1e6j1mu9Wlg784KBziixM2MijVfZyWvj/Ly95yrpwdag 8JKGEvwOaYPlDpecZfOMiH3rRdr3Kiqtz6n+j+QsP+r3ylCm4NIuOsrsm7Bn+3UewbYV 0bx+yy4l7lcE66buO8AkZVYCo/Arqb5s9Opeg6OsWYwifeD6Qk763ETcTG6MgLe6Vy2a woUQ== X-Gm-Message-State: AC+VfDwqPbBJT06nYrZv1mmHd4bBdZ1oBh1nESqwW/+WRztSSCacR2+t 1ro2cE58W4q95tRwO8FIyUo81In6RM7tVRb6 X-Google-Smtp-Source: ACHHUZ53BaQ3IWMDiSD/9ydEo3S9fenNHEm7zgrZw941KuYic4L3B4+t1YiwvBZYRXPaOZh79K0r7Q== X-Received: by 2002:ac2:5623:0:b0:4eb:30f9:eed7 with SMTP id b3-20020ac25623000000b004eb30f9eed7mr824674lff.22.1683632122133; Tue, 09 May 2023 04:35:22 -0700 (PDT) Received: from localhost.localdomain (93-80-66-133.broadband.corbina.ru. [93.80.66.133]) by smtp.googlemail.com with ESMTPSA id k16-20020ac24570000000b004f25ccac240sm108940lfm.74.2023.05.09.04.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 04:35:21 -0700 (PDT) From: Ivan Mikhaylov To: Samuel Mendoza-Jonas , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Ivan Mikhaylov Subject: [PATCH v2 5/5] dt-bindings: net: ftgmac100: convert to yaml version from txt Date: Tue, 9 May 2023 14:35:04 +0000 Message-Id: <20230509143504.30382-6-fr0st61te@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509143504.30382-1-fr0st61te@gmail.com> References: <20230509143504.30382-1-fr0st61te@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Signed-off-by: Ivan Mikhaylov --- .../bindings/net/faraday,ftgmac100.yaml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml diff --git a/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml new file mode 100644 index 000000000000..98cd142f74bb --- /dev/null +++ b/Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/faraday,ftgmac100.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Faraday Technology FTGMAC100 gigabit ethernet controller + +allOf: + - $ref: "ethernet-controller.yaml#" + +maintainers: + - Po-Yu Chuang + +properties: + compatible: + oneOf: + - const: faraday,ftgmac100 + - items: + - enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac + - const: faraday,ftgmac100 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + description: | + In accordance with the generic clock bindings. Must describe the MAC + IP clock, and optionally an RMII RCLK gate for the AST2500/AST2600. The + required MAC clock must be the first cell. + minItems: 1 + maxItems: 2 + + clock-names: + items: + - enum: + - MACCLK + - RCLK + + phy-mode: + enum: + - rgmii + - rmii + + phy-handle: true + + use-ncsi: + description: | + Use the NC-SI stack instead of an MDIO PHY. Currently assumes + rmii (100bT) but kept as a separate property in case NC-SI grows support + for a gigabit link. + type: boolean + + no-hw-checksum: + description: | + Used to disable HW checksum support. Here for backward + compatibility as the driver now should have correct defaults based on + the SoC. + type: boolean + + mac-address-increment: + description: | + Increment the MAC address taken by GMA command via NC-SI. Specifies + a signed number to be added to the host MAC address as obtained by + the OEM GMA command. If not specified, 1 is used by default for + Broadcom and Intel network cards, 0 otherwise. + + mdio: + $ref: /schemas/net/mdio.yaml# + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + mac0: ethernet@1e660000 { + compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + reg = <0x1e660000 0x180>; + interrupts = <2>; + use-ncsi; + }; + + mac1: ethernet@1e680000 { + compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + reg = <0x1e680000 0x180>; + interrupts = <2>; + + phy-handle = <&phy>; + phy-mode = "rgmii"; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + }; + };