From patchwork Tue Sep 23 13:14:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Jing D" X-Patchwork-Id: 465 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 22803B3B2; Tue, 23 Sep 2014 15:12:58 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 17D1B333 for ; Tue, 23 Sep 2014 15:12:50 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 23 Sep 2014 06:14:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,580,1406617200"; d="scan'208";a="604019026" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 23 Sep 2014 06:14:24 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id s8NDEMao012303; Tue, 23 Sep 2014 21:14:22 +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 s8NDEKpb001323; Tue, 23 Sep 2014 21:14:22 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s8NDEKEB001319; Tue, 23 Sep 2014 21:14:20 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Tue, 23 Sep 2014 21:14:06 +0800 Message-Id: <1411478047-1251-6-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411478047-1251-1-git-send-email-jing.d.chen@intel.com> References: <1411478047-1251-1-git-send-email-jing.d.chen@intel.com> Subject: [dpdk-dev] [PATCH 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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) Acked-by: Konstantin Ananyev Acked-by: Jingjing Wu Acked-by: Jijiang Liu Acked-by: Huawei Xie --- lib/librte_pmd_i40e/i40e_ethdev.c | 91 +++++++++++++++++------------------- 1 files changed, 43 insertions(+), 48 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index a267c96..3185654 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1532,45 +1532,37 @@ 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_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"); - return; - } - - if (is_same_ether_addr(mac_addr, &(pf->dev_addr))) { - PMD_DRV_LOG(INFO, "Ignore adding permanent mac 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\n", + pf->flags | I40E_FLAG_VMDQ ? "configured" : "enabled", + pool); 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\n", + 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); + if (pool == 0) + vsi = pf->main_vsi; + else + vsi = pf->vmdq[pool - 1].vsi; ret = i40e_vsi_add_mac(vsi, mac_addr); if (ret != I40E_SUCCESS) { - PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter"); + PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter\n"); return; } - - ether_addr_copy(mac_addr, &pf->dev_addr); - i40e_vsi_delete_mac(vsi, &old_mac); } /* Remove a MAC address, and update filters */ @@ -1578,36 +1570,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\n"); + 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\n"); + return; + } + } + } } static int