From patchwork Fri May 29 10:01:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shradha Shah X-Patchwork-Id: 477754 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 5E9BE140E45 for ; Fri, 29 May 2015 20:02:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755690AbbE2KCY (ORCPT ); Fri, 29 May 2015 06:02:24 -0400 Received: from nbfkord-smmo01.seg.att.com ([209.65.160.76]:46374 "EHLO nbfkord-smmo01.seg.att.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753839AbbE2KCW (ORCPT ); Fri, 29 May 2015 06:02:22 -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 e2938655.2b628a27c940.2091286.00-2460.11731500.nbfkord-smmo01.seg.att.com (envelope-from ); Fri, 29 May 2015 10:02:22 +0000 (UTC) X-MXL-Hash: 5568392e10e107b1-a7ae31167f91bc9e1da7906547ca60874d23e5b5 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 2f838655.0.2091178.00-1962.11730814.nbfkord-smmo01.seg.att.com (envelope-from ); Fri, 29 May 2015 10:01:23 +0000 (UTC) X-MXL-Hash: 556838f327883139-47847287a68e4d011d89395fd1a6f5d2d307b5c3 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:19 -0700 Message-ID: <556838ED.8020407@solarflare.com> Date: Fri, 29 May 2015 11:01:17 +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 02/14] sfc: Add sysfs entry for flags (link control and primary) 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--5.942100-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=Sq3XKJcP] X-AnalysisOut: [uCHF4Ca5ojsA:9 a=pILNOxqGKmIA:10 a=8h0IWT2zrbsZj0Wy:21 a=y] X-AnalysisOut: [Oh-kUVkbxeO9pw6: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 On every adapter there will be one primary PF per adaptor and one link control PF per port. Signed-off-by: Shradha Shah --- drivers/net/ethernet/sfc/ef10.c | 62 ++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 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 ee20d96..ebdf6ee 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -255,8 +255,34 @@ static ssize_t efx_ef10_show_physical_port(struct device *dev, return sprintf(buf, "%d\n", efx->port_num); } -static DEVICE_ATTR(physical_port, 0444, efx_ef10_show_physical_port, +static ssize_t efx_ef10_show_link_control_flag(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->mcdi->fn_flags) & + (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_LINKCTRL)) + ? 1 : 0); +} + +static ssize_t efx_ef10_show_primary_flag(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->mcdi->fn_flags) & + (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY)) + ? 1 : 0); +} + +static DEVICE_ATTR(physical_port, 0444, efx_ef10_show_physical_port, NULL); +static DEVICE_ATTR(link_control_flag, 0444, efx_ef10_show_link_control_flag, NULL); +static DEVICE_ATTR(primary_flag, 0444, efx_ef10_show_primary_flag, NULL); static int efx_ef10_probe(struct efx_nic *efx) { @@ -323,32 +349,41 @@ static int efx_ef10_probe(struct efx_nic *efx) if (rc) goto fail3; - rc = efx_ef10_get_pf_index(efx); + rc = device_create_file(&efx->pci_dev->dev, + &dev_attr_link_control_flag); if (rc) goto fail3; + rc = device_create_file(&efx->pci_dev->dev, &dev_attr_primary_flag); + if (rc) + goto fail4; + + rc = efx_ef10_get_pf_index(efx); + if (rc) + goto fail5; + rc = efx_ef10_init_datapath_caps(efx); if (rc < 0) - goto fail3; + goto fail5; efx->rx_packet_len_offset = ES_DZ_RX_PREFIX_PKTLEN_OFST - ES_DZ_RX_PREFIX_SIZE; rc = efx_mcdi_port_get_number(efx); if (rc < 0) - goto fail3; + goto fail5; efx->port_num = rc; rc = device_create_file(&efx->pci_dev->dev, &dev_attr_physical_port); if (rc) - goto fail3; + goto fail5; rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr); if (rc) - goto fail4; + goto fail6; rc = efx_ef10_get_sysclk_freq(efx); if (rc < 0) - goto fail4; + goto fail6; efx->timer_quantum_ns = 1536000 / rc; /* 1536 cycles */ @@ -368,7 +403,7 @@ static int efx_ef10_probe(struct efx_nic *efx) nic_data->workaround_35388 = enabled & MC_CMD_GET_WORKAROUNDS_OUT_BUG35388; } else if (rc != -ENOSYS && rc != -ENOENT) { - goto fail4; + goto fail6; } netif_dbg(efx, probe, efx->net_dev, @@ -377,14 +412,18 @@ static int efx_ef10_probe(struct efx_nic *efx) rc = efx_mcdi_mon_probe(efx); if (rc && rc != -EPERM) - goto fail4; + goto fail6; efx_ptp_probe(efx, NULL); return 0; -fail4: +fail6: device_remove_file(&efx->pci_dev->dev, &dev_attr_physical_port); +fail5: + device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); +fail4: + device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); fail3: efx_mcdi_fini(efx); fail2: @@ -629,6 +668,9 @@ static void efx_ef10_remove(struct efx_nic *efx) device_remove_file(&efx->pci_dev->dev, &dev_attr_physical_port); + device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); + device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); + efx_mcdi_fini(efx); efx_nic_free_buffer(efx, &nic_data->mcdi_buf); kfree(nic_data);