From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E28652B8F for ; Wed, 7 Dec 2016 15:26:21 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP; 07 Dec 2016 06:26:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="39808988" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29]) ([10.237.220.29]) by orsmga005.jf.intel.com with ESMTP; 07 Dec 2016 06:26:19 -0800 To: Wenzhuo Lu , dev@dpdk.org References: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com> <1481081535-37448-1-git-send-email-wenzhuo.lu@intel.com> <1481081535-37448-17-git-send-email-wenzhuo.lu@intel.com> Cc: Bernard Iremonger From: Ferruh Yigit Message-ID: Date: Wed, 7 Dec 2016 14:26:19 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1481081535-37448-17-git-send-email-wenzhuo.lu@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 16/32] net/i40e: add set VF VLAN insert function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2016 14:26:22 -0000 On 12/7/2016 3:31 AM, Wenzhuo Lu wrote: > Support inserting VF VLAN id from PF. > User can call the API on PF to insert a VLAN id to a > specific VF. Same comment with prev patch, does it make sense to insert " from PF" to patch title? > > Signed-off-by: Bernard Iremonger > --- > drivers/net/i40e/i40e_ethdev.c | 53 +++++++++++++++++++++++++++++++ > drivers/net/i40e/rte_pmd_i40e.h | 19 +++++++++++ > drivers/net/i40e/rte_pmd_i40e_version.map | 1 + > 3 files changed, 73 insertions(+) > > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c > index 253209b..c571d8b 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -10361,3 +10361,56 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev, > else > return -EINVAL; > } > + > +int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id, > + uint16_t vlan_id) > +{ > + struct rte_eth_dev *dev; > + struct rte_eth_dev_info dev_info; > + struct i40e_pf *pf; > + struct i40e_pf_vf *vf; > + struct i40e_hw *hw; > + struct i40e_vsi *vsi; > + struct i40e_vsi_context ctxt; > + int ret; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); > + > + dev = &rte_eth_devices[port]; > + rte_eth_dev_info_get(port, &dev_info); > + > + pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); > + hw = I40E_PF_TO_HW(pf); > + > + /** > + * return -ENODEV if SRIOV not enabled, VF number not configured > + * or no queue assigned. > + */ > + if (!hw->func_caps.sr_iov_1_1 || pf->vf_num == 0 || > + pf->vf_nb_qps == 0) > + return -ENODEV; > + > + if (vf_id > pf->vf_num) This check was [1] in prev patches: [1] if (vf_id > pf->vf_num - 1 || !pf->vfs) > + return -EINVAL; > + > + if (vlan_id > 4095) Can there be any define in base driver for this? Or ETH_VLAN_ID_MAX perhaps? > + return -EINVAL; > + > + vf = &pf->vfs[vf_id]; > + vsi = vf->vsi; > + > + vsi->info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_VLAN_VALID); > + vsi->info.port_vlan_flags |= I40E_AQ_VSI_PVLAN_INSERT_PVID; > + vsi->info.pvid = vlan_id; > + ---> > + memset(&ctxt, 0, sizeof(ctxt)); > + (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); > + ctxt.seid = vsi->seid; > + > + hw = I40E_VSI_TO_HW(vsi); > + ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); > + if (ret != I40E_SUCCESS) > + PMD_DRV_LOG(ERR, "Failed to update VSI params"); <----- If Wenzhuo prefers to extract this part into a function, it can be re-used here too. <...>