From patchwork Fri May 29 10:01:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shradha Shah X-Patchwork-Id: 477747 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 350E2140E45 for ; Fri, 29 May 2015 20:01:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755716AbbE2KBS (ORCPT ); Fri, 29 May 2015 06:01:18 -0400 Received: from nbfkord-smmo03.seg.att.com ([209.65.160.84]:21012 "EHLO nbfkord-smmo03.seg.att.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755077AbbE2KBQ (ORCPT ); Fri, 29 May 2015 06:01:16 -0400 Received: from unknown [12.187.104.25] (EHLO webmail.solarflare.com) by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-5) with ESMTP id ce838655.2adf86492940.2725070.00-2463.14711403.nbfkord-smmo03.seg.att.com (envelope-from ); Fri, 29 May 2015 10:01:16 +0000 (UTC) X-MXL-Hash: 556838ec19158524-b70bd3eb704fac9fc9e6e855e32ad56f255e0612 Received: from unknown [12.187.104.25] (EHLO webmail.solarflare.com) by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-5) over TLS secured channel with ESMTP id 6e838655.0.2725062.00-2325.14711336.nbfkord-smmo03.seg.att.com (envelope-from ); Fri, 29 May 2015 10:01:11 +0000 (UTC) X-MXL-Hash: 556838e70442c41f-9dbd918e374289c96f77bcea2502f29d5d7d864c 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; Fri, 29 May 2015 03:01:09 -0700 Message-ID: <556838E2.3040405@solarflare.com> Date: Fri, 29 May 2015 11:01:06 +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 01/14] sfc: Add sysfs entry for physical port References: <55683895.2090408@solarflare.com> In-Reply-To: <55683895.2090408@solarflare.com> X-Originating-IP: [10.17.20.135] X-TM-AS-Product-Ver: SMEX-10.0.0.1412-7.000.1014-21576.005 X-TM-AS-Result: No--6.755800-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-AnalysisOut: [v=2.0 cv=ZKpgbwHb 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=jmLzPupg] X-AnalysisOut: [N6dMxoq4P0YA:9 a=pILNOxqGKmIA:10 a=j4zpnlz08YkGVNyD:21 a=l] X-AnalysisOut: [1f9BkQCAQz-JTBb: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 In the case where we have multiple functions (PFs and VFs), this sysfs entry is useful to identify the physical port corresponding to the function we are interested in. Signed-off-by: Shradha Shah --- drivers/net/ethernet/sfc/ef10.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) -- 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 a547ceb..ee20d96 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -246,6 +246,18 @@ static int efx_ef10_get_mac_address_vf(struct efx_nic *efx, u8 *mac_address) return 0; } +static ssize_t efx_ef10_show_physical_port(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); + + return sprintf(buf, "%d\n", efx->port_num); +} + +static DEVICE_ATTR(physical_port, 0444, efx_ef10_show_physical_port, + NULL); + static int efx_ef10_probe(struct efx_nic *efx) { struct efx_ef10_nic_data *nic_data; @@ -326,14 +338,18 @@ static int efx_ef10_probe(struct efx_nic *efx) if (rc < 0) goto fail3; efx->port_num = rc; + rc = device_create_file(&efx->pci_dev->dev, &dev_attr_physical_port); + if (rc) + goto fail3; rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr); if (rc) - goto fail3; + goto fail4; rc = efx_ef10_get_sysclk_freq(efx); if (rc < 0) - goto fail3; + goto fail4; + efx->timer_quantum_ns = 1536000 / rc; /* 1536 cycles */ /* Check whether firmware supports bug 35388 workaround. @@ -341,9 +357,9 @@ static int efx_ef10_probe(struct efx_nic *efx) * ask if it's already enabled */ rc = efx_mcdi_set_workaround(efx, MC_CMD_WORKAROUND_BUG35388, true); - if (rc == 0) + if (rc == 0) { nic_data->workaround_35388 = true; - else if (rc == -EPERM) { + } else if (rc == -EPERM) { unsigned int enabled; rc = efx_mcdi_get_workarounds(efx, NULL, &enabled); @@ -351,21 +367,24 @@ static int efx_ef10_probe(struct efx_nic *efx) goto fail3; nic_data->workaround_35388 = enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG35388; + } else if (rc != -ENOSYS && rc != -ENOENT) { + goto fail4; } - else if (rc != -ENOSYS && rc != -ENOENT) - goto fail3; + netif_dbg(efx, probe, efx->net_dev, "workaround for bug 35388 is %sabled\n", nic_data->workaround_35388 ? "en" : "dis"); rc = efx_mcdi_mon_probe(efx); if (rc && rc != -EPERM) - goto fail3; + goto fail4; efx_ptp_probe(efx, NULL); return 0; +fail4: + device_remove_file(&efx->pci_dev->dev, &dev_attr_physical_port); fail3: efx_mcdi_fini(efx); fail2: @@ -608,6 +627,8 @@ static void efx_ef10_remove(struct efx_nic *efx) if (!nic_data->must_restore_piobufs) efx_ef10_free_piobufs(efx); + device_remove_file(&efx->pci_dev->dev, &dev_attr_physical_port); + efx_mcdi_fini(efx); efx_nic_free_buffer(efx, &nic_data->mcdi_buf); kfree(nic_data);