From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9E59E3798 for ; Sat, 27 May 2017 10:31:25 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2017 01:31:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,400,1491289200"; d="scan'208";a="1135329764" Received: from dpdk6.bj.intel.com ([172.16.182.81]) by orsmga001.jf.intel.com with ESMTP; 27 May 2017 01:31:23 -0700 From: Wei Dai To: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com, helin.zhang@intel.com, jingjing.wu@intel.com Cc: dev@dpdk.org, Wei Dai Date: Sat, 27 May 2017 16:22:07 +0800 Message-Id: <1495873329-43303-6-git-send-email-wei.dai@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495873329-43303-1-git-send-email-wei.dai@intel.com> References: <1495873329-43303-1-git-send-email-wei.dai@intel.com> Subject: [dpdk-dev] [PATCH 5/7] ethdev: add support of restoration of multicast addr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 May 2017 08:31:26 -0000 Signed-off-by: Wei Dai --- lib/librte_ether/rte_ethdev.c | 31 ++++++++++++++++++++++++++++++- lib/librte_ether/rte_ethdev.h | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0d9544c..78609f5 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -961,6 +961,20 @@ rte_eth_dev_mtu_restore(uint8_t port_id) } static void +rte_eth_dev_mc_addr_list_restore(uint8_t port_id) +{ + struct rte_eth_dev *dev; + + dev = &rte_eth_devices[port_id]; + + if (dev->data->mc_addr_count == 0) + return; + + rte_eth_dev_set_mc_addr_list(port_id, dev->data->mc_addr_list, + dev->data->mc_addr_count); +} + +static void rte_eth_dev_config_restore(uint8_t port_id) { struct rte_eth_dev *dev; @@ -1023,6 +1037,8 @@ rte_eth_dev_config_restore(uint8_t port_id) rte_eth_dev_link_status_restore(port_id); rte_eth_dev_mtu_restore(port_id); + + rte_eth_dev_mc_addr_list_restore(port_id); } int @@ -3423,12 +3439,25 @@ rte_eth_dev_set_mc_addr_list(uint8_t port_id, uint32_t nb_mc_addr) { struct rte_eth_dev *dev; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP); - return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr); + ret = dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr); + if (!ret) { + if (dev->data->mc_addr_list != NULL) + rte_free(dev->data->mc_addr_list); + dev->data->mc_addr_list = rte_zmalloc("dev->mc_addr_list", + sizeof(struct ether_addr) * nb_mc_addr, 0); + if (dev->data->mc_addr_list != NULL) { + rte_memcpy(dev->data->mc_addr_list, mc_addr_set, + sizeof(struct ether_addr) * nb_mc_addr); + dev->data->mc_addr_count = nb_mc_addr; + } + } + return ret; } int diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index aca8510..8f7e772 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1771,6 +1771,8 @@ struct rte_eth_dev_data { struct rte_eth_rx_queue_conf *rxq_conf; struct rte_eth_tx_queue_conf *txq_conf; + uint32_t mc_addr_count; + struct ether_addr *mc_addr_list; }; /** Device supports hotplug detach */ -- 2.7.4