From patchwork Wed Oct 19 14:47:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iremonger, Bernard" X-Patchwork-Id: 16721 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 F329272FD; Wed, 19 Oct 2016 16:47:44 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 63B0E6CCE for ; Wed, 19 Oct 2016 16:47:42 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 19 Oct 2016 07:47:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,514,1473145200"; d="scan'208";a="181477650" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga004.fm.intel.com with ESMTP; 19 Oct 2016 07:47:40 -0700 From: Bernard Iremonger To: dev@dpdk.org, daniels@research.att.com, wenzhuo.lu@intel.com, az5157@att.com Date: Wed, 19 Oct 2016 15:47:33 +0100 Message-Id: <1476888454-13859-2-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1476818007-13659-1-git-send-email-daniels@research.att.com> References: <1476818007-13659-1-git-send-email-daniels@research.att.com> Subject: [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix VLAN insert parameter type and its use 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: "E. Scott Daniels" The final parameter to rte_pmd_ixgbe_set_vf_vlan_insert is uint8_t and treated as a binary flag when it needs to be a uint16_t and treated as a VLAN id. The data sheet (sect 8.2.3.27.13) describes the right most 16 bits as the VLAN id that is to be inserted; the 16.11 code is accepting only a 1 or 0 thus effectively only allowing the VLAN id 1 to be inserted (0 disables the insertion setting). This patch changes the final parm name to represent the data that is being accepted (vlan_id), changes the type to permit all valid VLAN ids, and validates the parameter based on the range of 0 to 4095. Corresponding changes to prototype and documentation in the .h file. Fixes: 49e248223e9f71 ("net/ixgbe: add API for VF management") Signed-off-by: E. Scott Daniels --- drivers/net/ixgbe/ixgbe_ethdev.c | 8 ++++---- drivers/net/ixgbe/rte_pmd_ixgbe.h | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 4ca5747..316af73 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4727,7 +4727,7 @@ rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on) } int -rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on) +rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint16_t vlan_id) { struct ixgbe_hw *hw; uint32_t ctrl; @@ -4742,13 +4742,13 @@ rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on) if (vf >= dev_info.max_vfs) return -EINVAL; - if (on > 1) + if (vlan_id > 4095) return -EINVAL; hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf)); - if (on) { - ctrl = on; + if (vlan_id) { + ctrl = vlan_id; ctrl |= IXGBE_VMVIR_VLANA_DEFAULT; } else { ctrl = 0; diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h index 2fdf530..c2fb826 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.h +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h @@ -99,16 +99,17 @@ int rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on); * The port identifier of the Ethernet device. * @param vf * ID specifying VF. - * @param on - * 1 - Enable VF's vlan insert. - * 0 - Disable VF's vlan insert + * @param vlan_id + * 0 - Disable VF's vlan insert. + * n - Enable; n is inserted as the vlan id. * * @return * - (0) if successful. * - (-ENODEV) if *port* invalid. * - (-EINVAL) if bad parameter. */ -int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on); +int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, + uint16_t vlan_id); /** * Enable/Disable tx loopback