From patchwork Thu Apr 13 00:29: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: 13209542 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00FA8C77B77 for ; Wed, 12 Apr 2023 21:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbjDLV3T (ORCPT ); Wed, 12 Apr 2023 17:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjDLV3S (ORCPT ); Wed, 12 Apr 2023 17:29:18 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC8B61BE; Wed, 12 Apr 2023 14:29:16 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id e3so4616629ljn.1; Wed, 12 Apr 2023 14:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681334955; 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=Gf1Kh5uQzs3C5TGP5BVbMx6BF/0Z+MG9RXtrMz1RDgM=; b=GkXYQ/3beNepeO3usBEwjwoDTlL8QGlWGIQ/aF3svhoBZEwQLr1SCHRMg4xKhcdeJr /Fvq6jbZfV6pnSftbXF+TGTJt6LQQHzP0g8V2c0Xq3nKUfxTdkhK7H5sHvKfbzU3qG7+ zkL0+F7EyX1ZUJTAXUwIM4nKgjOPWGiCGr++2TkUMYfdSMXomltUxQLFQQBV2sdi9Df3 TpdtmCxW+As3NH+yHY3VXdqx6zk4tHkEZniI2gXlgqTJCTR0dm/Zp9I1E9GyLeuvapdc 0aRKyI/yOH1Umqlep1Hk6uOI2xq3iQuQx1hwsROlRWvso6LJ3kNiQS2qwAxvc+U6ondm BCVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681334955; 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=Gf1Kh5uQzs3C5TGP5BVbMx6BF/0Z+MG9RXtrMz1RDgM=; b=k0UKCVOp+nu5H6E+kiJ3rpl07HYqO4eE8frMHT/HgNMudUQ6sGeVoHyI9S6jCTxS0E JDdfrqN7n9I+qO26HKRVZ/dPge53kgLRRajebbPCCQE5/LKv7LPJcRT3tNRnDAvcKuGJ XEZ0GXh71x30gNgF2gQa8aMO6xlx0rndYuWeOjY/ewiTG1pjHKEi7bhFcJsI9k/IKJ/d YT8V49qjYr9HMD4+spgKctBBfpt7GzXUncysIXU/Mmxv6FpkoKsGpGr0RZ0z9DZ1h6hn buLN496OUFEQdpi/wEkP1fgo7wQVWPv9p0wKMHMRw7Zfis075mFObYwyqPJoZzJXyIus Zu2w== X-Gm-Message-State: AAQBX9fgyRjCk6dj7rK4vJn0E2DKHcLXVtqwdj5FuLBvaj6sJ9qM30r+ OBa3ajUD25wBwSFufyclSM0= X-Google-Smtp-Source: AKy350YsA11yAODO6cQEvGeRv+XcnYg8ZwmfbqA/a0ZN7yoxXNuF2g+6V+85Fb+18kioaXmyv/JRoA== X-Received: by 2002:a05:651c:d5:b0:2a7:6f60:34f2 with SMTP id 21-20020a05651c00d500b002a76f6034f2mr21442ljr.33.1681334955193; Wed, 12 Apr 2023 14:29:15 -0700 (PDT) Received: from localhost.localdomain (93-80-67-75.broadband.corbina.ru. [93.80.67.75]) by smtp.googlemail.com with ESMTPSA id p14-20020a2e804e000000b002a7758b13c9sm1882481ljg.52.2023.04.12.14.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 14:29:14 -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, Ivan Mikhaylov Subject: [PATCH 1/4] net/ncsi: make one oem_gma function for all mfr id Date: Thu, 13 Apr 2023 00:29:02 +0000 Message-Id: <20230413002905.5513-2-fr0st61te@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413002905.5513-1-fr0st61te@gmail.com> References: <20230413002905.5513-1-fr0st61te@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 Thu Apr 13 00:29: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: 13209543 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CEFCC77B76 for ; Wed, 12 Apr 2023 21:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbjDLV3V (ORCPT ); Wed, 12 Apr 2023 17:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjDLV3T (ORCPT ); Wed, 12 Apr 2023 17:29:19 -0400 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 E1C5665B3; Wed, 12 Apr 2023 14:29:17 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id h12so11534109lfj.8; Wed, 12 Apr 2023 14:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681334956; 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=Hk7xrlNRg2LjZhR5nnd2KHymPvx3zfiMgU5M+lLV6HU=; b=V/xeUYZxj1igJ0+uiSoZIThxos0Sd6GZlIIVkJz4YN5x1DicEctqTz+qWmxpPzfU0H NVt6SkFV70FUOxLccgZKXxavU8ENzRuJEbfUcvN774ef2sN3nv5mQx6vDBrB3WEBUj8b NqxbasXTDaFJ4UbgNpIYwmBLvUBhYqr0+aVySBcwmUFbiT6jANbYfqSGllOIzJT1rDvJ y3q96lE+DE8SNQ6YftOGBq08Y4pRitxCfqhGSvUQ3tQSuOwCFoWHNxMsuLvRlyeJieRP dGgOuYCnd4VkWLf+pTT56YeqjQgvnkvayNMm1mgDCv+HQLpnEKI/3VX9VxXjhBznjgnn 8cTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681334956; 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=Hk7xrlNRg2LjZhR5nnd2KHymPvx3zfiMgU5M+lLV6HU=; b=AGun8RJ4Pahfalhi74fvKU0bTCKEdS2E/Y9qD8E+zMmseV0+GtvymnlwCZwPbUjNjR IviQ1MU1eV7MEp9F0ojbviJ6bNKTctmYKkqKQ56TgeX2sW/UTUVjM8mXWdjFIXWpBNRa XjEP8oIIgSZBA3bSQDHcSwFG+QQdnzNPlgZodp2NIidgAeZaiZpGQodaHy3St9POO/+m 10GmZ2dP1p/HHvMV5Ll/yOT/E0SWZPCgrjjD8aVZYRJUvcaITHIN8xoRLJq9aWjxbCdl h60k69lc8zOJWsq6c4EIPZI6Q1vCDuFWiuu92U4p2/IdxHb2r0i7n7S5wfaodz8Ffsmi eTMA== X-Gm-Message-State: AAQBX9ceLMISlmubv92NgpJyHBxpghUieOMtl//B9JDgPwCM9ewWgWm3 R24qowYNUme4Rb07IKd+C8U= X-Google-Smtp-Source: AKy350Ye1GA676YQ4BN6dYLkL9CQQn88C/Cbl2rh/iPRc7tBj4iZYzuChU7PL/iQBKOFJguk8wSagA== X-Received: by 2002:a05:6512:38cc:b0:4eb:53f7:a569 with SMTP id p12-20020a05651238cc00b004eb53f7a569mr60214lft.63.1681334956325; Wed, 12 Apr 2023 14:29:16 -0700 (PDT) Received: from localhost.localdomain (93-80-67-75.broadband.corbina.ru. [93.80.67.75]) by smtp.googlemail.com with ESMTPSA id p14-20020a2e804e000000b002a7758b13c9sm1882481ljg.52.2023.04.12.14.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 14:29:15 -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, Ivan Mikhaylov , Paul Fertser Subject: [PATCH 2/4] net/ncsi: change from ndo_set_mac_address to dev_set_mac_address Date: Thu, 13 Apr 2023 00:29:03 +0000 Message-Id: <20230413002905.5513-3-fr0st61te@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413002905.5513-1-fr0st61te@gmail.com> References: <20230413002905.5513-1-fr0st61te@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Thu Apr 13 00:29: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: 13209544 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF044C77B6E for ; Wed, 12 Apr 2023 21:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbjDLV3Z (ORCPT ); Wed, 12 Apr 2023 17:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjDLV3X (ORCPT ); Wed, 12 Apr 2023 17:29:23 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33DFA7D9E; Wed, 12 Apr 2023 14:29:18 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id z26so12892087ljq.3; Wed, 12 Apr 2023 14:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681334957; 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=456QAvvtFsJz9MlnBR4BMWWfSHxyYmN8x4WUjQvR230=; b=ZEfLFAkeRU2gIWo8oNm4F2yRm3hBbNC/T914gFb4O09VoZ8GEaSwZ3KHPdWKgRGxfS 6Xo2BbxEmF7YME+NVOP8MLjOvJK1uc+sRg5jlrZqvpA5TEqEy016BBKD1WgB4R4odsso TTY6mP7+SuTuNvxww/CMw47g1cfpEsaFZC/xYJGD/Pks1bCVDx4BmT1I/cspN7YxA3xl WqEj22ugjF5jCq6fKepkWWyvKpDtVwdvLhbBLsC23lUQNQQrb2Csj3GmmKr1ZVlS3u+Z 7oAgi3fTGcVvQ97cYaivN3KXgKgc1+3Rd2DzCPUQhYKGtbJPlFU+mz0GgzSgfzgHFM/Q bqVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681334957; 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=456QAvvtFsJz9MlnBR4BMWWfSHxyYmN8x4WUjQvR230=; b=EtFkwL7gApJXoRJ6ZHfGp6mxTSS8SpzHPXc+0tu5N+6Vgx49W9v8AyuJTLVksLJ4IG N32jx7lvQEHPKZ087a54DoZ4Lgb6cDv+vucIB6y/OOtbFn+BOigkN06bUKNTVWZXag4P DdabHap6GXQp+EdR913XZ/PdlgQRqwOzKH9bXECb8DPcmVHuBLvhJSmJaD95HNl6fS2n YSzuNqSaNDUD8GYSOwYLnWCgQzOu4VBr4+hE+sj9U+bel82kw6WNM/Z6GqRxFjCIdXfS UFYgavMFz7XXftzVjjtuDZ0sv3Pko2lyue+Ew838PHVY8w0ogdN53gEtteq5imWoQmtf QSHw== X-Gm-Message-State: AAQBX9cYS7IKlJxTopdW+1yG4NHkPG06LIHWcp20x6nSbueXSLsnAsub Q8ngGJ/N66VKGWI6JLHllLM= X-Google-Smtp-Source: AKy350Z/K5A6wvUUtoxhM9asteWT3QdOauvOoPj7FRaYuOul6Xh7e5It0qADBdsDxG0E+/CS74OGOQ== X-Received: by 2002:a2e:9a83:0:b0:2a7:84b5:f360 with SMTP id p3-20020a2e9a83000000b002a784b5f360mr23112lji.39.1681334957269; Wed, 12 Apr 2023 14:29:17 -0700 (PDT) Received: from localhost.localdomain (93-80-67-75.broadband.corbina.ru. [93.80.67.75]) by smtp.googlemail.com with ESMTPSA id p14-20020a2e804e000000b002a7758b13c9sm1882481ljg.52.2023.04.12.14.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 14:29:16 -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, Ivan Mikhaylov , Paul Fertser Subject: [PATCH 3/4] net/ftgmac100: add mac-address-increment option for GMA command from NC-SI Date: Thu, 13 Apr 2023 00:29:04 +0000 Message-Id: <20230413002905.5513-4-fr0st61te@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413002905.5513-1-fr0st61te@gmail.com> References: <20230413002905.5513-1-fr0st61te@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add s32 mac-address-increment option for Get MAC Address command from NC-SI. Signed-off-by: Paul Fertser Signed-off-by: Ivan Mikhaylov --- Documentation/devicetree/bindings/net/ftgmac100.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ftgmac100.txt b/Documentation/devicetree/bindings/net/ftgmac100.txt index 29234021f601..7ef5329d888d 100644 --- a/Documentation/devicetree/bindings/net/ftgmac100.txt +++ b/Documentation/devicetree/bindings/net/ftgmac100.txt @@ -22,6 +22,10 @@ Optional properties: - use-ncsi: 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. +- mac-address-increment: 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. - no-hw-checksum: Used to disable HW checksum support. Here for backward compatibility as the driver now should have correct defaults based on the SoC. From patchwork Thu Apr 13 00:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Mikhaylov X-Patchwork-Id: 13209545 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 354A2C77B6E for ; Wed, 12 Apr 2023 21:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjDLV33 (ORCPT ); Wed, 12 Apr 2023 17:29:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbjDLV3Y (ORCPT ); Wed, 12 Apr 2023 17:29:24 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9297EC1; Wed, 12 Apr 2023 14:29:19 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id by8so13157137ljb.13; Wed, 12 Apr 2023 14:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681334958; 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=Qp6LyIaTjuBGZ4eQdu84T77cz5sFNOTq+6H0iaPWSIo=; b=U+rLnvmAKOQNiK3Ab8LtIRiH+ieLN/gC1CsMYe3pl996C9JvK1LbXg2npsOx7mZTds OgftBb1HigpM71CRbeyBo6L9B/v58rp6GQhQvSfBma8O69e8K7nXhaKhfd6MrKK6USdb Na0pTQi4GqDuNCwxFjWQqcHAmdVVfQbDLNZnMR1IxXmJifqiU9UqDaOpzqYlcSPETrMS 51b/tT/389zSyIos+o7mt0NAFTHlkprcf/7EpbTU3RVKvJOUgucS/5aQADUTjldWoZFJ 5E6wco7U95XgEQCeh+lF6qBwwOlkM6a7ZOVeyTO8fUmVTQ+PKcnohH7zlsHly9TQR4/X dm/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681334958; 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=Qp6LyIaTjuBGZ4eQdu84T77cz5sFNOTq+6H0iaPWSIo=; b=lP4tr5vKW2blERy9tL5fdmXK6x4OyBBV82JRAh5lZe/Sj6ZmYoGJh+n+Pjb8lF65D5 MK6EquGJA8cwkmX+sUx1fXSFVpd4QkaXFoomtE9zzinP6oOU7vqb3aWZEkvXJ7PPhcah FASXHjB1NONqvaUn2YkzXvN4lEEtOViozTOs5TA83dVCNXXfLmEEIajId7f02GRBDtft wy5ndFN82p0HEq4YbEDC/X69PBo1vLHw5tevFREVRLZY3qVJ1fnaD9e3prFgKY/uL++/ BosqNqlTwqvndjXVweNTIn76M5xHQSuaH2Og2QRcFjwjP1cfEnIAUqwWpUUqWtAVE/Y6 Mxfw== X-Gm-Message-State: AAQBX9cfuw7Cbj9utzgK0RLNVqlsdaW836I/o10nooSEHiXYXhrRg2vf KG1wwe2F3LpUhPf6wK6XJGQ= X-Google-Smtp-Source: AKy350aldqAfGI10vxdfzvcAzNPZ/ZfmZHdfrVy8JYZwKIOZ/iF1zeFrRzQz63bmJUIMS2oN0qw/Qg== X-Received: by 2002:a2e:7006:0:b0:2a7:6f97:51bb with SMTP id l6-20020a2e7006000000b002a76f9751bbmr24003ljc.31.1681334958253; Wed, 12 Apr 2023 14:29:18 -0700 (PDT) Received: from localhost.localdomain (93-80-67-75.broadband.corbina.ru. [93.80.67.75]) by smtp.googlemail.com with ESMTPSA id p14-20020a2e804e000000b002a7758b13c9sm1882481ljg.52.2023.04.12.14.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 14:29: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, Ivan Mikhaylov Subject: [PATCH 4/4] net/ncsi: add shift MAC address property Date: Thu, 13 Apr 2023 00:29:05 +0000 Message-Id: <20230413002905.5513-5-fr0st61te@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413002905.5513-1-fr0st61te@gmail.com> References: <20230413002905.5513-1-fr0st61te@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 compatibility. 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;