From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3E1241B1A7 for ; Tue, 26 Sep 2017 16:04:04 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 07:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,441,1500966000"; d="scan'208";a="1199172300" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 07:04:03 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Sep 2017 07:04:03 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Sep 2017 07:04:02 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.98]) with mapi id 14.03.0319.002; Tue, 26 Sep 2017 22:04:00 +0800 From: "Wu, Jingjing" To: "Hunt, David" , "dev@dpdk.org" CC: "Ananyev, Konstantin" , "Sexton, Rory" , "Marjanovic, Nemanja" Thread-Topic: [PATCH v2 1/8] net/i40e: add API to convert VF MAC to VSI index Thread-Index: AQHTNfskJ+FlMa4C7EKK7yEUqTJ9/qLHM5bg Date: Tue, 26 Sep 2017 14:04:00 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810E8022E@SHSMSX103.ccr.corp.intel.com> References: <1503676941-80981-1-git-send-email-david.hunt@intel.com> <1506342429-199695-1-git-send-email-david.hunt@intel.com> <1506342429-199695-2-git-send-email-david.hunt@intel.com> In-Reply-To: <1506342429-199695-2-git-send-email-david.hunt@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2QyZDI2MDgtYzZhZC00OWQ2LWFmZTgtNzBjODMzYjE0ODEwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkNza1JPTjRMYlh5dDY5N0Q3cHFheERDR1BGMXhKTmVXVE94dVBxNHBzamM9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/8] net/i40e: add API to convert VF MAC to VSI index 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: Tue, 26 Sep 2017 14:04:04 -0000 > -----Original Message----- > From: Hunt, David > Sent: Monday, September 25, 2017 8:27 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; Wu, Jingjing > ; Sexton, Rory ; Marjanovic= , Nemanja > ; Hunt, David > Subject: [PATCH v2 1/8] net/i40e: add API to convert VF MAC to VSI index >=20 VSI index -> VF id. > From: "Sexton, Rory" >=20 > Need a way to convert a vf id to a pf id on the host so as to query the p= f > for relevant statistics which are used for the frequency changes in the > vm_power_manager app. Used when profiles are passed down from the guest > to the host, allowing the host to map the vfs to pfs. >=20 > Signed-off-by: Nemanja Marjanovic > Signed-off-by: Rory Sexton > Signed-off-by: David Hunt > --- > drivers/net/i40e/rte_pmd_i40e.c | 35 +++++++++++++++++++++++++++++++++++ > drivers/net/i40e/rte_pmd_i40e.h | 13 +++++++++++++ > 2 files changed, 48 insertions(+) >=20 > diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i= 40e.c > index f12b7f4..85b540f 100644 > --- a/drivers/net/i40e/rte_pmd_i40e.c > +++ b/drivers/net/i40e/rte_pmd_i40e.c > @@ -2115,3 +2115,38 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t por= t, >=20 > return 0; > } > + > +uint64_t > +rte_pmd_i40e_query_vfid_by_mac(uint8_t port, uint64_t vf_mac) { > + struct rte_eth_dev *dev; > + struct ether_addr *vf_mac_addr =3D (struct ether_addr *)&vf_mac; > + struct ether_addr *mac; > + struct i40e_pf *pf; > + int i, x; > + struct i40e_pf_vf *vf; > + uint16_t vf_num; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); > + dev =3D &rte_eth_devices[port]; > + > + if (!is_i40e_supported(dev)) > + return -ENOTSUP; > + > + pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); > + vf_num =3D pf->vf_num; > + > + for (x =3D 0; x < vf_num; x++) { > + int mac_addr_matches =3D 1; > + vf =3D &pf->vfs[x]; > + mac =3D &vf->mac_addr; > + > + for (i =3D 0; i < ETHER_ADDR_LEN; i++) { > + if (mac->addr_bytes[i] !=3D vf_mac_addr->addr_bytes[i]) > + mac_addr_matches =3D 0; > + } You can use is_same_ether_addr instead. > + if (mac_addr_matches) > + return x; > + } > + > + return -EINVAL; > +} > diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i= 40e.h > index 356fa89..6984105 100644 > --- a/drivers/net/i40e/rte_pmd_i40e.h > +++ b/drivers/net/i40e/rte_pmd_i40e.h > @@ -637,4 +637,17 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port, > uint8_t mask, > uint32_t pkt_type); >=20 > +/** > + * Translate a VF mac address into VF index in array of pf->vfs VF id is a command concept, no need to say it is the index in pf->vfs > + * > + * @param port > + * pointer to port identifier of the device > + * @param vf_mac > + * the mac address of the vf to determine index of > + * @return > + * -(-22 EINVAL) the vf mac does not exist on this port > + * -(!-22) the index of vfid in pf->vfs Thanks Jingjing