From patchwork Wed May 20 10:09:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shradha Shah X-Patchwork-Id: 474314 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F3CDE140077 for ; Wed, 20 May 2015 20:09:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbbETKJx (ORCPT ); Wed, 20 May 2015 06:09:53 -0400 Received: from nbfkord-smmo01.seg.att.com ([209.65.160.76]:37575 "EHLO nbfkord-smmo01.seg.att.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbbETKJv (ORCPT ); Wed, 20 May 2015 06:09:51 -0400 Received: from unknown [12.187.104.25] (EHLO webmail.solarflare.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-5) with ESMTP id f6d5c555.2b6244c0d940.664041.00-2459.3749945.nbfkord-smmo01.seg.att.com (envelope-from ); Wed, 20 May 2015 10:09:51 +0000 (UTC) X-MXL-Hash: 555c5d6f06e0da67-bcf5fc8d390d052ff7931d80350756123255919c Received: from unknown [12.187.104.25] (EHLO webmail.solarflare.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-5) over TLS secured channel with ESMTP id d6d5c555.0.664037.00-2034.3749926.nbfkord-smmo01.seg.att.com (envelope-from ); Wed, 20 May 2015 10:09:50 +0000 (UTC) X-MXL-Hash: 555c5d6e0dac0a0d-d62fe38c30b16a49feee5de983a639b04d2e4c8c Received: from sshah-desktop.uk.level5networks.com (10.17.20.135) by webmail.SolarFlare.com (10.20.40.31) with Microsoft SMTP Server (TLS) id 14.3.158.1; Wed, 20 May 2015 03:09:48 -0700 Message-ID: <555C5D6A.5090705@solarflare.com> Date: Wed, 20 May 2015 11:09:46 +0100 From: Shradha Shah User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: David Miller CC: , Subject: [PATCH net-next v3 06/16] sfc: Store the efx_nic struct of the current VF in the VF data struct References: <555C5C91.4000004@solarflare.com> In-Reply-To: <555C5C91.4000004@solarflare.com> X-Originating-IP: [10.17.20.135] X-TM-AS-Product-Ver: SMEX-10.0.0.1412-7.000.1014-21556.005 X-TM-AS-Result: No--8.456600-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-AnalysisOut: [v=2.0 cv=fudrkiEf c=1 sm=1 a=MkjXnYnS3dyNWGSWLXxFFQ==:17 a] X-AnalysisOut: [=5ZTteq0x3j8A:10 a=3VnyBeAh6Z0A:10 a=BLceEmwcHowA:10 a=N65] X-AnalysisOut: [9UExz7-8A:10 a=zRKbQ67AAAAA:8 a=h1PgugrvaO0A:10 a=ePZzVz_t] X-AnalysisOut: [qZTjmJnG-9EA:9 a=pILNOxqGKmIA:10 a=KaHqLJKFzcALdmgR:21 a=H] X-AnalysisOut: [wEEyOGXWYVmRN5K:21] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2014051901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.25] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Initialised in efx_probe_vf and removal is dealt with in efx_ef10_remove. vf->efx is needed in future patches to change the MAC address of the VF via the parent PF, while the driver is bound to the VF. Example: ip link set dev vf NUM mac LLADDR Signed-off-by: Shradha Shah --- drivers/net/ethernet/sfc/ef10.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/ethernet/sfc/ef10_sriov.c | 3 +++ drivers/net/ethernet/sfc/ef10_sriov.h | 2 ++ 3 files changed, 37 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 8b6579a..78d3236 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -544,6 +544,25 @@ static void efx_ef10_remove(struct efx_nic *efx) struct efx_ef10_nic_data *nic_data = efx->nic_data; int rc; +#ifdef CONFIG_SFC_SRIOV + struct efx_ef10_nic_data *nic_data_pf; + struct pci_dev *pci_dev_pf; + struct efx_nic *efx_pf; + struct ef10_vf *vf; + + if (efx->pci_dev->is_virtfn) { + pci_dev_pf = efx->pci_dev->physfn; + if (pci_dev_pf) { + efx_pf = pci_get_drvdata(pci_dev_pf); + nic_data_pf = efx_pf->nic_data; + vf = nic_data_pf->vf + nic_data->vf_index; + vf->efx = NULL; + } else + netif_info(efx, drv, efx->net_dev, + "Could not get the PF id from VF\n"); + } +#endif + efx_ptp_remove(efx); efx_mcdi_mon_remove(efx); @@ -582,6 +601,19 @@ static int efx_ef10_probe_vf(struct efx_nic *efx) if (rc) goto fail; + if (efx->pci_dev->is_virtfn) { + if (efx->pci_dev->physfn) { + struct efx_nic *efx_pf = + pci_get_drvdata(efx->pci_dev->physfn); + struct efx_ef10_nic_data *nic_data_p = efx_pf->nic_data; + struct efx_ef10_nic_data *nic_data = efx->nic_data; + + nic_data_p->vf[nic_data->vf_index].efx = efx; + } else + netif_info(efx, drv, efx->net_dev, + "Could not get the PF id from VF\n"); + } + return 0; fail: diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c index 1b93acf..6208dd7 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.c +++ b/drivers/net/ethernet/sfc/ef10_sriov.c @@ -160,6 +160,8 @@ static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx) efx_ef10_vport_free(efx, vf->vport_id); vf->vport_id = 0; } + + vf->efx = NULL; } } @@ -215,6 +217,7 @@ static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx) for (i = 0; i < efx->vf_count; i++) { random_ether_addr(nic_data->vf[i].mac); + nic_data->vf[i].efx = NULL; rc = efx_ef10_sriov_assign_vf_vport(efx, i); if (rc) diff --git a/drivers/net/ethernet/sfc/ef10_sriov.h b/drivers/net/ethernet/sfc/ef10_sriov.h index 8b67163..6f27a0d 100644 --- a/drivers/net/ethernet/sfc/ef10_sriov.h +++ b/drivers/net/ethernet/sfc/ef10_sriov.h @@ -14,11 +14,13 @@ /** * struct ef10_vf - PF's store of VF data + * @efx: efx_nic struct for the current VF * @vport_id: vport ID for the VF * @vport_assigned: record whether the vport is currently assigned to the VF * @mac: MAC address for the VF, zero when address is removed from the vport */ struct ef10_vf { + struct efx_nic *efx; unsigned int vport_id; unsigned int vport_assigned; u8 mac[ETH_ALEN];