From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ferruh.yigit@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id C34F82BAF
 for <dev@dpdk.org>; Wed,  7 Dec 2016 15:42:53 +0100 (CET)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga102.fm.intel.com with ESMTP; 07 Dec 2016 06:42:52 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.33,310,1477983600"; d="scan'208";a="1069148146"
Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.29])
 ([10.237.220.29])
 by orsmga001.jf.intel.com with ESMTP; 07 Dec 2016 06:42:51 -0800
To: Wenzhuo Lu <wenzhuo.lu@intel.com>, 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>
 <a0331cec-719d-ac15-c833-eaab7f09ba90@intel.com>
Cc: Bernard Iremonger <bernard.iremonger@intel.com>
From: Ferruh Yigit <ferruh.yigit@intel.com>
Message-ID: <98778177-6aa9-f109-cb75-c223e0c9b019@intel.com>
Date: Wed, 7 Dec 2016 14:42:51 +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: <a0331cec-719d-ac15-c833-eaab7f09ba90@intel.com>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
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 <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: Wed, 07 Dec 2016 14:42:54 -0000

On 12/7/2016 2:26 PM, Ferruh Yigit wrote:
> 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 <bernard.iremonger@intel.com>
>> ---
>>  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?

Answer was in next patches, it seems we have two options (which is bad)

lib/librte_net/rte_ether.h
#define ETHER_MAX_VLAN_ID  4095 /**< Maximum VLAN ID. */

lib/librte_ether/rte_ethdev.h
#define ETH_VLAN_ID_MAX       0x0FFF /**< VLAN ID is in lower 12 bits*/

> 
>> +		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.
> 
> <...>
>