From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <zhetao@shecgisg004.sh.intel.com>
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by dpdk.org (Postfix) with ESMTP id 471CFDE6
 for <dev@dpdk.org>; Thu, 21 Jan 2016 07:50:14 +0100 (CET)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga104.fm.intel.com with ESMTP; 20 Jan 2016 22:49:57 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.22,324,1449561600"; d="scan'208";a="865220918"
Received: from shvmail01.sh.intel.com ([10.239.29.42])
 by orsmga001.jf.intel.com with ESMTP; 20 Jan 2016 22:49:56 -0800
Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com
 [10.239.29.89])
 by shvmail01.sh.intel.com with ESMTP id u0L6nsFk016216;
 Thu, 21 Jan 2016 14:49:54 +0800
Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1])
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id
 u0L6noCq020584; Thu, 21 Jan 2016 14:49:52 +0800
Received: (from zhetao@localhost)
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u0L6noxJ020580;
 Thu, 21 Jan 2016 14:49:50 +0800
From: Zhe Tao <zhe.tao@intel.com>
To: dev@dpdk.org
Date: Thu, 21 Jan 2016 14:49:44 +0800
Message-Id: <1453358984-20550-1-git-send-email-zhe.tao@intel.com>
X-Mailer: git-send-email 1.7.4.1
Subject: [dpdk-dev] [PATCH] i40e: add VEB switching support for i40e
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 21 Jan 2016 06:50:15 -0000

VEB switching feature for i40e is used to enable the switching between the
 VSIs connect to the virtual bridge. The old implementation is setting the
 virtual bridge mode as VEPA which is port aggregation. Enable the switching 
 ability by setting the loop back mode for the specific VSIs which connect to PF
 or VFs. 

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 48 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..ba2ba9e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3822,6 +3822,39 @@ i40e_vsi_get_bw_config(struct i40e_vsi *vsi)
 	return I40E_SUCCESS;
 }
 
+/* i40e_enable_pf_lb
+ * @pf: pointer to the pf structure
+ *
+ * allow loopback on pf
+ */
+static inline void
+i40e_enable_pf_lb(struct i40e_pf *pf)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi_context ctxt;
+	int ret;
+
+	memset(&ctxt, 0, sizeof(ctxt));
+	ctxt.seid = pf->main_vsi_seid;
+	ctxt.pf_num = hw->pf_id;
+	ret = i40e_aq_get_vsi_params(hw, &ctxt, NULL);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "cannot get pf vsi config, err %d, aq_err %d",
+			    ret, hw->aq.asq_last_status);
+		return;
+	}
+	ctxt.flags = I40E_AQ_VSI_TYPE_PF;
+	ctxt.info.valid_sections =
+		rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SWITCH_VALID);
+	ctxt.info.switch_id |=
+		rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
+
+	ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
+	if (ret)
+		PMD_DRV_LOG(ERR, "update vsi switch failed, aq_err=%d\n",
+			    hw->aq.asq_last_status);
+}
+
 /* Setup a VSI */
 struct i40e_vsi *
 i40e_vsi_setup(struct i40e_pf *pf,
@@ -3857,6 +3890,8 @@ i40e_vsi_setup(struct i40e_pf *pf,
 			PMD_DRV_LOG(ERR, "VEB setup failed");
 			return NULL;
 		}
+		/* set ALLOWLOOPBACk on pf, when veb is created */
+		i40e_enable_pf_lb(pf);
 	}
 
 	vsi = rte_zmalloc("i40e_vsi", sizeof(struct i40e_vsi), 0);
@@ -4029,14 +4064,11 @@ i40e_vsi_setup(struct i40e_pf *pf,
 		ctxt.connection_type = 0x1;
 		ctxt.flags = I40E_AQ_VSI_TYPE_VF;
 
-		/**
-		 * Do not configure switch ID to enable VEB switch by
-		 * I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB. Because in Fortville,
-		 * if the source mac address of packet sent from VF is not
-		 * listed in the VEB's mac table, the VEB will switch the
-		 * packet back to the VF. Need to enable it when HW issue
-		 * is fixed.
-		 */
+		/* Configure switch ID */
+		ctxt.info.valid_sections |=
+			rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SWITCH_VALID);
+		ctxt.info.switch_id =
+			rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
 
 		/* Configure port/vlan */
 		ctxt.info.valid_sections |=
-- 
2.1.4