From patchwork Fri Jun 3 02:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 13190 X-Patchwork-Delegate: bruce.richardson@intel.com 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 5929A5A9F; Fri, 3 Jun 2016 04:59:25 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 158255A93 for ; Fri, 3 Jun 2016 04:59:22 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 02 Jun 2016 19:59:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,409,1459839600"; d="scan'208";a="979925348" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 02 Jun 2016 19:59:21 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u532xJwl028117; Fri, 3 Jun 2016 10:59:19 +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 u532xGlZ002923; Fri, 3 Jun 2016 10:59:18 +0800 Received: (from beileixi@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u532xGs0002919; Fri, 3 Jun 2016 10:59:16 +0800 From: Beilei Xing To: wenzhuo.lu@intel.com Cc: dev@dpdk.org, Beilei Xing Date: Fri, 3 Jun 2016 10:59:15 +0800 Message-Id: <1464922755-2888-1-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1461228948-18820-1-git-send-email-beilei.xing@intel.com> References: <1461228948-18820-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v2] e1000: configure VLAN TPID 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" This patch enables configuring the ether types of both inner and outer VLANs. Note that outer TPID of single VLAN and inner TPID of double VLAN are read only. Signed-off-by: Beilei Xing Acked-by: Xiao Wang --- v2 changes: Modify return value. Cause inner tpid is not supported by single vlan, return -ENOTSUP. Add return value. If want to set inner TPID of double vlan or set outer tpid of single vlan, return -ENOTSUP. drivers/net/e1000/igb_ethdev.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index f0921ee..5d37e2c 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -86,6 +86,14 @@ #define E1000_INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT) #define E1000_TSAUXC_DISABLE_SYSTIME 0x80000000 +/* CTRL_EXT bit mask*/ +#define E1000_CTRL_EXT_EXT_VLAN (1 << 26) + +/* VLAN Ether Type bit mask */ +#define E1000_VET_VET_EXT 0xFFFF0000 + +#define E1000_VET_VET_EXT_SHIFT 16 + static int eth_igb_configure(struct rte_eth_dev *dev); static int eth_igb_start(struct rte_eth_dev *dev); static void eth_igb_stop(struct rte_eth_dev *dev); @@ -2237,13 +2245,37 @@ eth_igb_vlan_tpid_set(struct rte_eth_dev *dev, { struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t reg = ETHER_TYPE_VLAN; + uint32_t reg; + uint32_t qinq; int ret = 0; + qinq = E1000_READ_REG(hw, E1000_CTRL_EXT); + qinq &= E1000_CTRL_EXT_EXT_VLAN; + switch (vlan_type) { case ETH_VLAN_TYPE_INNER: - reg |= (tpid << 16); - E1000_WRITE_REG(hw, E1000_VET, reg); + if (qinq) { + ret = -ENOTSUP; + PMD_DRV_LOG(WARNING, + "Inner vlan ether type is read-only\n"); + } else { + ret = -ENOTSUP; + PMD_DRV_LOG(ERR, "Inner type is not supported" + " by single vlan\n"); + } + break; + case ETH_VLAN_TYPE_OUTER: + if (qinq) { + reg = E1000_READ_REG(hw, E1000_VET); + reg = (reg & (~E1000_VET_VET_EXT)) | + ((uint32_t)tpid << E1000_VET_VET_EXT_SHIFT); + E1000_WRITE_REG(hw, E1000_VET, reg); + } else { + ret = -ENOTSUP; + PMD_DRV_LOG(WARNING, + "Single vlan ether type is read-only\n"); + } + break; default: ret = -EINVAL;