From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 0F5087E99 for ; Tue, 4 Nov 2014 10:53:14 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 04 Nov 2014 02:00:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,312,1413270000"; d="scan'208";a="631028200" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 04 Nov 2014 02:01:51 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id sA4A1nL9022052; Tue, 4 Nov 2014 18:01:49 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sA4A1k2T029030; Tue, 4 Nov 2014 18:01:48 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id sA4A1kwc029026; Tue, 4 Nov 2014 18:01:46 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Tue, 4 Nov 2014 18:01:28 +0800 Message-Id: <1415095289-28961-6-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1415095289-28961-1-git-send-email-jing.d.chen@intel.com> References: <1411478047-1251-2-git-send-email-jing.d.chen@intel.com> <1415095289-28961-1-git-send-email-jing.d.chen@intel.com> Subject: [dpdk-dev] [PATCH v3 5/6] i40e: macaddr add/del enhancement X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Nov 2014 09:53:15 -0000 From: "Chen Jing D(Mark)" Change i40e_macaddr_add and i40e_macaddr_remove functions to support multiple macaddr add/delete. In the meanwhile, support macaddr ops on different pools. Signed-off-by: Chen Jing D(Mark) --- lib/librte_pmd_i40e/i40e_ethdev.c | 90 +++++++++++++++++------------------- 1 files changed, 43 insertions(+), 47 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index 020881f..21401f8 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1573,48 +1573,41 @@ i40e_priority_flow_ctrl_set(__rte_unused struct rte_eth_dev *dev, static void i40e_macaddr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, - __attribute__((unused)) uint32_t index, - __attribute__((unused)) uint32_t pool) + __rte_unused uint32_t index, + uint32_t pool) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_mac_filter_info mac_filter; - struct i40e_vsi *vsi = pf->main_vsi; - struct ether_addr old_mac; + struct i40e_vsi *vsi; int ret; - if (!is_valid_assigned_ether_addr(mac_addr)) { - PMD_DRV_LOG(ERR, "Invalid ethernet address"); + /* If VMDQ not enabled or configured, return */ + if (pool != 0 && (!(pf->flags | I40E_FLAG_VMDQ) || !pf->nb_cfg_vmdq_vsi)) { + PMD_DRV_LOG(ERR, "VMDQ not %s, can't set mac to pool %u", + pf->flags | I40E_FLAG_VMDQ ? "configured" : "enabled", + pool); return; } - if (is_same_ether_addr(mac_addr, &(pf->dev_addr))) { - PMD_DRV_LOG(INFO, "Ignore adding permanent mac address"); - return; - } - - /* Write mac address */ - ret = i40e_aq_mac_address_write(hw, I40E_AQC_WRITE_TYPE_LAA_ONLY, - mac_addr->addr_bytes, NULL); - if (ret != I40E_SUCCESS) { - PMD_DRV_LOG(ERR, "Failed to write mac address"); + if (pool > pf->nb_cfg_vmdq_vsi) { + PMD_DRV_LOG(ERR, "Pool number %u invalid. Max pool is %u", + pool, pf->nb_cfg_vmdq_vsi); return; } - (void)rte_memcpy(&old_mac, hw->mac.addr, ETHER_ADDR_LEN); - (void)rte_memcpy(hw->mac.addr, mac_addr->addr_bytes, - ETHER_ADDR_LEN); (void)rte_memcpy(&mac_filter.mac_addr, mac_addr, ETHER_ADDR_LEN); mac_filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; + if (pool == 0) + vsi = pf->main_vsi; + else + vsi = pf->vmdq[pool - 1].vsi; + ret = i40e_vsi_add_mac(vsi, &mac_filter); if (ret != I40E_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter"); return; } - - ether_addr_copy(mac_addr, &pf->dev_addr); - i40e_vsi_delete_mac(vsi, &old_mac); } /* Remove a MAC address, and update filters */ @@ -1622,36 +1615,39 @@ static void i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - struct i40e_vsi *vsi = pf->main_vsi; - struct rte_eth_dev_data *data = I40E_VSI_TO_DEV_DATA(vsi); + struct i40e_vsi *vsi; + struct rte_eth_dev_data *data = dev->data; struct ether_addr *macaddr; int ret; - struct i40e_hw *hw = - I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (index >= vsi->max_macaddrs) - return; + uint32_t i; + uint64_t pool_sel; macaddr = &(data->mac_addrs[index]); - if (!is_valid_assigned_ether_addr(macaddr)) - return; - - ret = i40e_aq_mac_address_write(hw, I40E_AQC_WRITE_TYPE_LAA_ONLY, - hw->mac.perm_addr, NULL); - if (ret != I40E_SUCCESS) { - PMD_DRV_LOG(ERR, "Failed to write mac address"); - return; - } - - (void)rte_memcpy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN); - ret = i40e_vsi_delete_mac(vsi, macaddr); - if (ret != I40E_SUCCESS) - return; + pool_sel = dev->data->mac_pool_sel[index]; + + for (i = 0; i < sizeof(pool_sel) * CHAR_BIT; i++) { + if (pool_sel & (1ULL << i)) { + if (i == 0) + vsi = pf->main_vsi; + else { + /* No VMDQ pool enabled or configured */ + if (!(pf->flags | I40E_FLAG_VMDQ) || + (i > pf->nb_cfg_vmdq_vsi)) { + PMD_DRV_LOG(ERR, "No VMDQ pool enabled" + "/configured"); + return; + } + vsi = pf->vmdq[i - 1].vsi; + } + ret = i40e_vsi_delete_mac(vsi, macaddr); - /* Clear device address as it has been removed */ - if (is_same_ether_addr(&(pf->dev_addr), macaddr)) - memset(&pf->dev_addr, 0, sizeof(struct ether_addr)); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to remove MACVLAN filter"); + return; + } + } + } } /* Set perfect match or hash match of MAC and VLAN for a VF */ -- 1.7.7.6