[dpdk-dev,5/6] i40e: macaddr add/del enhancement
diff mbox

Message ID 1411478047-1251-6-git-send-email-jing.d.chen@intel.com
State Superseded, archived
Headers show

Commit Message

Chen, Jing D Sept. 23, 2014, 1:14 p.m. UTC
From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>

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) <jing.d.chen@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>
---
 lib/librte_pmd_i40e/i40e_ethdev.c |   91 +++++++++++++++++-------------------
 1 files changed, 43 insertions(+), 48 deletions(-)

Comments

Thomas Monjalon Oct. 14, 2014, 2:25 p.m. UTC | #1
2014-09-23 21:14, Chen Jing D:
> +		PMD_DRV_LOG(ERR, "VMDQ not %s, can't set mac to pool %u\n",
> +			pf->flags | I40E_FLAG_VMDQ ? "configured" : "enabled",
> +			pool);
[...]
> -	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);
[...]
> -		PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter");
> +		PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter\n");
[...]
> +				PMD_DRV_LOG(ERR, "Failed to remove MACVLAN filter\n");

I'm pretty sure you rebased this patch and solved the conflicts without
updating your patch accordingly. Indeed carriage returns have been removed
from logs recently.
Hint: rebase conflicts are really often meaningful ;)
Chen, Jing D Oct. 15, 2014, 7:01 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Tuesday, October 14, 2014 10:25 PM
> To: Chen, Jing D
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 5/6] i40e: macaddr add/del enhancement
> 
> 2014-09-23 21:14, Chen Jing D:
> > +		PMD_DRV_LOG(ERR, "VMDQ not %s, can't set mac to
> pool %u\n",
> > +			pf->flags | I40E_FLAG_VMDQ ? "configured" :
> "enabled",
> > +			pool);
> [...]
> > -	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);
> [...]
> > -		PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter");
> > +		PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter\n");
> [...]
> > +				PMD_DRV_LOG(ERR, "Failed to remove
> MACVLAN filter\n");
> 
> I'm pretty sure you rebased this patch and solved the conflicts without
> updating your patch accordingly. Indeed carriage returns have been removed
> from logs recently.
> Hint: rebase conflicts are really often meaningful ;)
> 

Thanks for your suggestion.

> --
> Thomas

Patch
diff mbox

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