From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6D2E3B62 for ; Tue, 22 Jan 2019 09:37:22 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2019 00:37:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,505,1539673200"; d="scan'208";a="293385838" Received: from dpdk26.sh.intel.com ([10.67.110.164]) by orsmga005.jf.intel.com with ESMTP; 22 Jan 2019 00:37:20 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Date: Tue, 22 Jan 2019 16:42:22 +0800 Message-Id: <1548146542-69346-1-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dpdk-dev] [PATCH] net/ice: add promiscuous mode support 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: Tue, 22 Jan 2019 08:37:23 -0000 Enable the APIs for unicast and multicast promiscuous mode setting. Signed-off-by: Wenzhuo Lu --- doc/guides/nics/features/ice.ini | 2 + drivers/net/ice/ice_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/doc/guides/nics/features/ice.ini b/doc/guides/nics/features/ice.ini index 8b1e22e..5e6cb4b 100644 --- a/doc/guides/nics/features/ice.ini +++ b/doc/guides/nics/features/ice.ini @@ -14,6 +14,8 @@ MTU update = Y Jumbo frame = Y Scattered Rx = Y TSO = Y +Promiscuous mode = Y +Allmulticast mode = Y Unicast MAC filter = Y Multicast MAC filter = Y RSS hash = Y diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index b145d9c..b450115 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -38,6 +38,10 @@ static int ice_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf); static int ice_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf); +static void ice_promisc_enable(struct rte_eth_dev *dev); +static void ice_promisc_disable(struct rte_eth_dev *dev); +static void ice_allmulti_enable(struct rte_eth_dev *dev); +static void ice_allmulti_disable(struct rte_eth_dev *dev); static int ice_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); @@ -103,6 +107,10 @@ static int ice_xstats_get_names(struct rte_eth_dev *dev, .reta_query = ice_rss_reta_query, .rss_hash_update = ice_rss_hash_update, .rss_hash_conf_get = ice_rss_hash_conf_get, + .promiscuous_enable = ice_promisc_enable, + .promiscuous_disable = ice_promisc_disable, + .allmulticast_enable = ice_allmulti_enable, + .allmulticast_disable = ice_allmulti_disable, .rx_queue_intr_enable = ice_rx_queue_intr_enable, .rx_queue_intr_disable = ice_rx_queue_intr_disable, .fw_version_get = ice_fw_version_get, @@ -1709,6 +1717,7 @@ static int ice_init_rss(struct ice_pf *pf) struct rte_eth_dev_data *data = dev->data; struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; uint16_t nb_rxq = 0; uint16_t nb_txq, i; int ret; @@ -1743,6 +1752,14 @@ static int ice_init_rss(struct ice_pf *pf) if (ice_rxq_intr_setup(dev)) return -EIO; + /* Enable receiving broadcast packets and transmitting packets */ + ret = ice_set_vsi_promisc(hw, vsi->idx, + ICE_PROMISC_BCAST_RX | ICE_PROMISC_BCAST_TX | + ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX, + 0); + if (ret != ICE_SUCCESS) + PMD_DRV_LOG(INFO, "fail to set vsi broadcast"); + ret = ice_aq_set_event_mask(hw, hw->port_info->lport, ((u16)(ICE_AQ_LINK_EVENT_LINK_FAULT | ICE_AQ_LINK_EVENT_PHY_TEMP_ALARM | @@ -2556,6 +2573,75 @@ static int ice_macaddr_set(struct rte_eth_dev *dev, return 0; } +static void +ice_promisc_enable(struct rte_eth_dev *dev) +{ + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; + uint8_t pmask; + uint16_t status; + + pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX | + ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX; + + status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0); + if (status != ICE_SUCCESS) + PMD_DRV_LOG(ERR, "Failed to enable promisc, err=%d", status); +} + +static void +ice_promisc_disable(struct rte_eth_dev *dev) +{ + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; + uint16_t status; + uint8_t pmask; + + pmask = ICE_PROMISC_UCAST_RX | ICE_PROMISC_UCAST_TX | + ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX; + + status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0); + if (status != ICE_SUCCESS) + PMD_DRV_LOG(ERR, "Failed to clear promisc, err=%d", status); +} + +static void +ice_allmulti_enable(struct rte_eth_dev *dev) +{ + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; + uint8_t pmask; + uint16_t status; + + pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX; + + status = ice_set_vsi_promisc(hw, vsi->idx, pmask, 0); + if (status != ICE_SUCCESS) + PMD_DRV_LOG(ERR, "Failed to enable allmulti, err=%d", status); +} + +static void +ice_allmulti_disable(struct rte_eth_dev *dev) +{ + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; + uint16_t status; + uint8_t pmask; + + if (dev->data->promiscuous == 1) + return; /* must remain in all_multicast mode */ + + pmask = ICE_PROMISC_MCAST_RX | ICE_PROMISC_MCAST_TX; + + status = ice_clear_vsi_promisc(hw, vsi->idx, pmask, 0); + if (status != ICE_SUCCESS) + PMD_DRV_LOG(ERR, "Failed to clear allmulti, err=%d", status); +} + static int ice_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) { -- 1.9.3