From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 3A02D1B173 for ; Wed, 24 Jan 2018 16:38:04 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E675022415; Wed, 24 Jan 2018 10:38:03 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:38:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=PvV9fR7v05p1z1fpB SLlLgVo4FgwbxNjK1mxkCxJvHw=; b=Ec5gX5cKTLCsdh3Tpli3xYV0Q9KBkjt/l b6DtbjIEEdLS+OUghJrKXjs3eXU9jcSW7fBhvFgBVRLlIjopaUnGcGsgTa2NhRWQ 5Oce/1GVlQXTMqdnEBL1Z0RW+DpgyW7r+rqQ0gzQ0TGnYrw+C9FP16Xn5u8vUcC8 BLPJl8ZlL8i/qsX9acIBh4KS28XHb3zHRgB1ZIbIt3CXUXB/VAfXI2+jjwCA+7r4 xot/a/bIqPLoQtZU9R6VxDn5YZYQ08JhHEe4XM77Ze5ciWTNNOUKpIuuXrpye907 y2ylc/yAEAB7kL7Ke341IPVugVUyTnyTSx8TBEC0nPEEK8mQPuN2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=PvV9fR7v05p1z1fpBSLlLgVo4FgwbxNjK1mxkCxJvHw=; b=h9aQggFv eyUtqdlQDvD7PuNQ3o5JnQ/kJWZNNSonQRbJtIHZluKH3ENEfD5D9SStmx/atauK BxLe7zmQ8RviVvWL+gJaU/9VorHjcpruXMQMfwvk/8ZRiYa9GhBxKHSvJDaxJ+Z8 n5Gvx5CkfTa/8EhXf8WX56NoUVPV0zMGkOPeuw0LMWBLo8IwBFMSJoLv1mM2UM0k a/24BkA1U6kiKNGi9vFTIFA5HIqbsV9JPuBkeaF6XtuRl3qfy4A3tPAx+JpNWDEV ygL4d2r3ni8D5xtAtInCvV0TkwcnUH8+w0nR+Hz8HCNQtVHC/LNyvKdneybUH10Y Y2Kkl1V8sORXNg== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id B79CF7E1A2; Wed, 24 Jan 2018 10:38:01 -0500 (EST) From: Yuanhan Liu To: Ivan Malov Cc: Andrew Rybchenko , dpdk stable Date: Wed, 24 Jan 2018 23:31:58 +0800 Message-Id: <1516808026-25523-50-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/sfc: fix main MAC address handling' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:38:04 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 3e73ef459b548207b0851d4a29f60befdfa650dd Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Wed, 20 Dec 2017 09:52:14 +0000 Subject: [PATCH] net/sfc: fix main MAC address handling [ upstream commit 642088ddff841783f27b4a73f50c917ea2cfa953 ] There is a school of thought that rte_eth_dev_default_mac_addr_set() must call the PMD callback first and then save the new MAC address in dev->data->mac_addrs[0]. If this concept gets approved, it will break the current approach used in sfc driver as the latter relies on the assumption that the new MAC address is already contained in dev->data->mac_addrs[0], and, if adapter restart is needed to make the HW apply the new address, the outdated value will be retrieved from dev->data. In order to preclude any possible bugs, this patch adds device private storage for the up-to-date copy of the address. Fixes: c100fd464bb7 ("net/sfc: support main MAC address change") Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_ethdev.c | 19 ++++++++++++++++--- drivers/net/sfc/sfc_port.c | 10 ++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 7f11bf2..b72eba0 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -158,6 +158,8 @@ struct sfc_port { boolean_t promisc; boolean_t allmulti; + struct ether_addr default_mac_addr; + unsigned int max_mcast_addrs; unsigned int nb_mcast_addrs; uint8_t *mcast_addrs; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2f5f86f..fabcc32 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -926,6 +926,12 @@ sfc_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) sfc_adapter_lock(sa); + /* + * Copy the address to the device private data so that + * it could be recalled in the case of adapter restart. + */ + ether_addr_copy(mac_addr, &port->default_mac_addr); + if (port->isolated) { sfc_err(sa, "isolated mode is active on the port"); sfc_err(sa, "will not set MAC address"); @@ -961,9 +967,9 @@ sfc_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) /* * Since setting MAC address with filters installed is not - * allowed on the adapter, one needs to simply restart adapter - * so that the new MAC address will be taken from an outer - * storage and set flawlessly by means of sfc_start() call + * allowed on the adapter, the new MAC address will be set + * by means of adapter restart. sfc_start() shall retrieve + * the new address from the device private data and set it. */ sfc_stop(sa); rc = sfc_start(sa); @@ -972,6 +978,13 @@ sfc_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) } unlock: + /* + * In the case of failure sa->port->default_mac_addr does not + * need rollback since no error code is returned, and the upper + * API will anyway update the external MAC address storage. + * To be consistent with that new value it is better to keep + * the device private value the same. + */ sfc_adapter_unlock(sa); } diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 6cfd0e3..5254394 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -188,10 +188,10 @@ sfc_port_start(struct sfc_adapter *sa) goto fail_mac_pdu_set; if (!port->isolated) { - struct ether_addr *mac_addrs = sa->eth_dev->data->mac_addrs; + struct ether_addr *addr = &port->default_mac_addr; sfc_log_init(sa, "set MAC address"); - rc = efx_mac_addr_set(sa->nic, mac_addrs[0].addr_bytes); + rc = efx_mac_addr_set(sa->nic, addr->addr_bytes); if (rc != 0) goto fail_mac_addr_set; @@ -342,6 +342,8 @@ int sfc_port_attach(struct sfc_adapter *sa) { struct sfc_port *port = &sa->port; + const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + const struct ether_addr *from; long kvarg_stats_update_period_ms; int rc; @@ -353,6 +355,10 @@ sfc_port_attach(struct sfc_adapter *sa) port->flow_ctrl = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE; port->flow_ctrl_autoneg = B_TRUE; + RTE_BUILD_BUG_ON(sizeof(encp->enc_mac_addr) != sizeof(*from)); + from = (const struct ether_addr *)(encp->enc_mac_addr); + ether_addr_copy(from, &port->default_mac_addr); + port->max_mcast_addrs = EFX_MAC_MULTICAST_LIST_MAX; port->nb_mcast_addrs = 0; port->mcast_addrs = rte_calloc_socket("mcast_addr_list_buf", -- 2.7.4