linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re:[PATCH net-next] net/ncsi: allow to customize BMC MAC Address offset
@ 2019-08-07 17:36 Vijay Khemka
  2019-08-08  4:51 ` [PATCH " Tao Ren
  0 siblings, 1 reply; 16+ messages in thread
From: Vijay Khemka @ 2019-08-07 17:36 UTC (permalink / raw)
  To: Tao Ren, Samuel Mendoza-Jonas, David S . Miller, netdev,
	linux-kernel, openbmc, William Kennington, Joel Stanley

Lgtm except one small comment below.

On 8/6/19, 5:22 PM, "openbmc on behalf of Tao Ren" <openbmc-bounces+vijaykhemka=fb.com@lists.ozlabs.org on behalf of taoren@fb.com> wrote:

    Currently BMC's MAC address is calculated by adding 1 to NCSI NIC's base
    MAC address when CONFIG_NCSI_OEM_CMD_GET_MAC option is enabled. The logic
    doesn't work for platforms with different BMC MAC offset: for example,
    Facebook Yamp BMC's MAC address is calculated by adding 2 to NIC's base
    MAC address ("BaseMAC + 1" is reserved for Host use).
    
    This patch adds NET_NCSI_MC_MAC_OFFSET config option to customize offset
    between NIC's Base MAC address and BMC's MAC address. Its default value is
    set to 1 to avoid breaking existing users.
    
    Signed-off-by: Tao Ren <taoren@fb.com>
    ---
     net/ncsi/Kconfig    |  8 ++++++++
     net/ncsi/ncsi-rsp.c | 15 +++++++++++++--
     2 files changed, 21 insertions(+), 2 deletions(-)
    
    diff --git a/net/ncsi/Kconfig b/net/ncsi/Kconfig
    index 2f1e5756c03a..be8efe1ed99e 100644
    --- a/net/ncsi/Kconfig
    +++ b/net/ncsi/Kconfig
    @@ -17,3 +17,11 @@ config NCSI_OEM_CMD_GET_MAC
     	---help---
     	  This allows to get MAC address from NCSI firmware and set them back to
     		controller.
    +config NET_NCSI_MC_MAC_OFFSET
    +	int
    +	prompt "Offset of Management Controller's MAC Address"
    +	depends on NCSI_OEM_CMD_GET_MAC
    +	default 1
    +	help
    +	  This defines the offset between Network Controller's (base) MAC
    +	  address and Management Controller's MAC address.
    diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
    index 7581bf919885..24a791f9ebf5 100644
    --- a/net/ncsi/ncsi-rsp.c
    +++ b/net/ncsi/ncsi-rsp.c
    @@ -656,6 +656,11 @@ static int ncsi_rsp_handler_oem_bcm_gma(struct ncsi_request *nr)
     	struct ncsi_rsp_oem_pkt *rsp;
     	struct sockaddr saddr;
     	int ret = 0;
    +#ifdef CONFIG_NET_NCSI_MC_MAC_OFFSET
    +	int mac_offset = CONFIG_NET_NCSI_MC_MAC_OFFSET;
    +#else
    +	int mac_offset = 1;
    +#endif
     
     	/* Get the response header */
     	rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp);
    @@ -663,8 +668,14 @@ static int ncsi_rsp_handler_oem_bcm_gma(struct ncsi_request *nr)
     	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);
    +
    +	/* Management Controller's MAC address is calculated by adding
    +	 * the offset to Network Controller's (base) MAC address.
    +	 * Note: negative offset is "ignored", and BMC will use the Base
Just mention negative and zero offset is ignored. As you are ignoring 0 as well.

    +	 * MAC address in this case.
    +	 */
    +	while (mac_offset-- > 0)
    +		eth_addr_inc((u8 *)saddr.sa_data);
     	if (!is_valid_ether_addr((const u8 *)saddr.sa_data))
     		return -ENXIO;
     
    -- 
    2.17.1
    
    


^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH net-next] net/ncsi: allow to customize BMC MAC Address offset
@ 2019-08-07  0:21 Tao Ren
  2019-08-07 18:25 ` Jakub Kicinski
  0 siblings, 1 reply; 16+ messages in thread
From: Tao Ren @ 2019-08-07  0:21 UTC (permalink / raw)
  To: Samuel Mendoza-Jonas, David S . Miller, netdev, linux-kernel,
	openbmc, William Kennington, Joel Stanley
  Cc: Tao Ren

Currently BMC's MAC address is calculated by adding 1 to NCSI NIC's base
MAC address when CONFIG_NCSI_OEM_CMD_GET_MAC option is enabled. The logic
doesn't work for platforms with different BMC MAC offset: for example,
Facebook Yamp BMC's MAC address is calculated by adding 2 to NIC's base
MAC address ("BaseMAC + 1" is reserved for Host use).

This patch adds NET_NCSI_MC_MAC_OFFSET config option to customize offset
between NIC's Base MAC address and BMC's MAC address. Its default value is
set to 1 to avoid breaking existing users.

Signed-off-by: Tao Ren <taoren@fb.com>
---
 net/ncsi/Kconfig    |  8 ++++++++
 net/ncsi/ncsi-rsp.c | 15 +++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/net/ncsi/Kconfig b/net/ncsi/Kconfig
index 2f1e5756c03a..be8efe1ed99e 100644
--- a/net/ncsi/Kconfig
+++ b/net/ncsi/Kconfig
@@ -17,3 +17,11 @@ config NCSI_OEM_CMD_GET_MAC
 	---help---
 	  This allows to get MAC address from NCSI firmware and set them back to
 		controller.
+config NET_NCSI_MC_MAC_OFFSET
+	int
+	prompt "Offset of Management Controller's MAC Address"
+	depends on NCSI_OEM_CMD_GET_MAC
+	default 1
+	help
+	  This defines the offset between Network Controller's (base) MAC
+	  address and Management Controller's MAC address.
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index 7581bf919885..24a791f9ebf5 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -656,6 +656,11 @@ static int ncsi_rsp_handler_oem_bcm_gma(struct ncsi_request *nr)
 	struct ncsi_rsp_oem_pkt *rsp;
 	struct sockaddr saddr;
 	int ret = 0;
+#ifdef CONFIG_NET_NCSI_MC_MAC_OFFSET
+	int mac_offset = CONFIG_NET_NCSI_MC_MAC_OFFSET;
+#else
+	int mac_offset = 1;
+#endif
 
 	/* Get the response header */
 	rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp);
@@ -663,8 +668,14 @@ static int ncsi_rsp_handler_oem_bcm_gma(struct ncsi_request *nr)
 	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);
+
+	/* Management Controller's MAC address is calculated by adding
+	 * the offset to Network Controller's (base) MAC address.
+	 * Note: negative offset is "ignored", and BMC will use the Base
+	 * MAC address in this case.
+	 */
+	while (mac_offset-- > 0)
+		eth_addr_inc((u8 *)saddr.sa_data);
 	if (!is_valid_ether_addr((const u8 *)saddr.sa_data))
 		return -ENXIO;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-08-14  0:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 17:36 Re:[PATCH net-next] net/ncsi: allow to customize BMC MAC Address offset Vijay Khemka
2019-08-08  4:51 ` [PATCH " Tao Ren
  -- strict thread matches above, loose matches on Subject: below --
2019-08-07  0:21 Tao Ren
2019-08-07 18:25 ` Jakub Kicinski
2019-08-07 18:41   ` Andrew Lunn
2019-08-08  4:48     ` Tao Ren
2019-08-08 13:32       ` Andrew Lunn
2019-08-08 19:02         ` Tao Ren
2019-08-08 21:16           ` Andrew Lunn
2019-08-08 22:26             ` Tao Ren
2019-08-08 23:03               ` Andrew Lunn
2019-08-09  5:29                 ` Tao Ren
     [not found]                   ` <10079A1AC4244A41BC7939A794B72C238FCE0E03@fmsmsx104.amr.corp.intel.com>
     [not found]                     ` <bc9da695-3fd3-6643-8e06-562cc08fbc62@linux.intel.com>
2019-08-13 16:31                       ` Terry Duncan
     [not found]                         ` <faa1b3c9-9ba3-0fff-e1d4-f6dddb60c52c@fb.com>
2019-08-13 20:54                           ` Terry Duncan
2019-08-14  0:22                             ` Terry Duncan
     [not found]                           ` <CH2PR15MB3686B3A20A231FC111C42F40A3D20@CH2PR15MB3686.namprd15.prod.outlook.com>
2019-08-13 21:15                             ` Terry Duncan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).