From patchwork Tue Apr 19 13:33:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 8880081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DECA79F1C1 for ; Tue, 19 Apr 2016 13:32:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC7B820263 for ; Tue, 19 Apr 2016 13:32:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 783C120268 for ; Tue, 19 Apr 2016 13:32:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1asVja-0003j7-NL; Tue, 19 Apr 2016 13:30:30 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1asVjV-0003Fo-JG for linux-arm-kernel@lists.infradead.org; Tue, 19 Apr 2016 13:30:27 +0000 Received: by mail-pf0-x243.google.com with SMTP id p185so1769946pfb.3 for ; Tue, 19 Apr 2016 06:30:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XauGu310LdHg2GVVOdDw7A7iGG4Aie1CLDM6Kvyhbpo=; b=p7I9tct4X2F4NXzuncTxtldm10EQ6vQGynWqI+6BD+HexRJPGu2my/feq070mXwIoZ AqBPi2CFEFc3m9SQSqZFyMwBVE2MzLDwWwoHjU/6NbslrW9XhFSrq+cL5k3u1MkTGxub zmaQJdCoBhc0GOOSFR2LlT2384TTskAIQ+1GR+T0r02vvdw7QiXyHK3bhiBu0+ygMwXv 0WAZamcZ1dLlWQHyj22EcbQGZHd6WMNZ/QD2SQv1ZbxZWyeJE7mprZHABWh35liBZX0d Av1pE28Nm9vt4isj3dZt/BESnwcGMLIdXmmbw8nnYgluR+wUjTNPLXKDQaLV7xBinNBJ xm/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XauGu310LdHg2GVVOdDw7A7iGG4Aie1CLDM6Kvyhbpo=; b=HkedYNQVxoWU/aLuerBYmTjQDnY3nst62e48LN2Q9B2lGimjvb1Y8oO1fUO5EIG9T5 xS++kbZkMxMryeuP9muxC1QSUxwepr8Awgl18Mk4SFEW5FVD9UaxW0H/MLztTfYN9isV wEQBZZPICi2FhlBCIVUNAAtNi2hCsGFdKCHELOLekGm+vl5nKTR9str1+b3rySerpd2J RUSFFN1Kj2DJw5IKUuMYvG9yYpLZLfJULymgPhtVv+zdjdBBLG+EfPmmrLDNzBVeYuZo 64BThqqeiLizYVPUC/hIAu9n5e+b7JgfuUJAb7AlthK4b1yKln0Y5B9hc3mZTjSi0UBK tkZQ== X-Gm-Message-State: AOPr4FU6cJdnmbaxACHhoiWIKy6UN3RI8rGbzPrjg4a6zIaMfbNq3iTRAT9JRsTmYRj8fg== X-Received: by 10.98.109.131 with SMTP id i125mr4019875pfc.153.1461072605793; Tue, 19 Apr 2016 06:30:05 -0700 (PDT) Received: from localhost.localdomain ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id s66sm91180360pfi.3.2016.04.19.06.30.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 06:30:04 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH 3/4] net: thunderx: add sysfs attribute for SQS/SVF assigments Date: Tue, 19 Apr 2016 19:03:31 +0530 Message-Id: <1461072812-44239-4-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1461072812-44239-1-git-send-email-sunil.kovvuri@gmail.com> References: <1461072812-44239-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160419_063025_760134_DA1C0547 X-CRM114-Status: GOOD ( 16.60 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Radoslaw Biernacki , sgoutham@cavium.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robert.richter@caviumnetworks.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Radoslaw Biernacki With this sysfs attribute (sriov_sqs_assignment) administrator will be able to read the current assigment of SQS/SVF for a given VF. This is useful to decide which VFs needs to be attached to UIO for a successful allocation of secondary Qsets Signed-off-by: Radoslaw Biernacki Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/nic_main.c | 67 +++++++++++++++++++++++- 1 files changed, 66 insertions(+), 1 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c index d6a6914..e2d8db9 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_main.c +++ b/drivers/net/ethernet/cavium/thunder/nic_main.c @@ -1159,6 +1159,60 @@ static void nic_poll_for_link(struct work_struct *work) queue_delayed_work(nic->check_link, &nic->dwork, HZ * 2); } +ssize_t sriov_sqs_assignment_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); + struct pci_dev *vf_dev; + struct pci_driver *vf_drv; + struct nicpf *nic = pci_get_drvdata(pdev); + size_t vf, off, svf_idx; + + off = scnprintf(buf, PAGE_SIZE, "%u\n", nic->num_vf_en); + + for (vf = 0; vf < nic->num_vf_en; vf++) { + vf_dev = nic->vf_pdev[vf]; + vf_drv = vf_dev ? pci_dev_driver(vf_dev) : NULL; + if (off >= PAGE_SIZE) + break; + off += scnprintf(&buf[off], PAGE_SIZE - off, + "%zu %04x:%02x:%02x.%d %s %c:", + vf, pci_domain_nr(vf_dev->bus), + vf_dev->bus->number, PCI_SLOT(vf_dev->devfn), + PCI_FUNC(vf_dev->devfn), + vf_drv ? vf_drv->name : "no-driver", + nic->vf_enabled[vf] ? '+' : '-'); + for (svf_idx = 0; svf_idx < MAX_SQS_PER_VF; svf_idx++) { + if (off >= PAGE_SIZE) + break; + if (nic->vf_sqs[vf][svf_idx] == NIC_VF_UNASSIGNED) + break; + off += scnprintf(&buf[off], PAGE_SIZE - off, " %d", + nic->vf_sqs[vf][svf_idx]); + } + if (off >= PAGE_SIZE) + break; + off += scnprintf(&buf[off], PAGE_SIZE - off, "\n"); + } + + for (vf = nic->num_vf_en; vf < nic->num_vf_en + nic->num_sqs_en; vf++) { + vf_dev = nic->vf_pdev[vf]; + vf_drv = vf_dev ? pci_dev_driver(vf_dev) : NULL; + if (off >= PAGE_SIZE) + break; + off += scnprintf(&buf[off], PAGE_SIZE - off, + "%zu %04x:%02x:%02x.%d %s: %u\n", + vf, pci_domain_nr(vf_dev->bus), + vf_dev->bus->number, PCI_SLOT(vf_dev->devfn), + PCI_FUNC(vf_dev->devfn), + vf_drv ? vf_drv->name : "no-driver", + nic->pqs_vf[vf]); + } + + return off; +} +DEVICE_ATTR_RO(sriov_sqs_assignment); + static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct device *dev = &pdev->dev; @@ -1235,12 +1289,18 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) goto err_unregister_interrupts; + err = device_create_file(dev, &dev_attr_sriov_sqs_assignment); + if (err) { + err = -ENOMEM; + goto err_disable_sriov; + } + /* Register a physical link status poll fn() */ nic->check_link = alloc_workqueue("check_link_status", WQ_UNBOUND | WQ_MEM_RECLAIM, 1); if (!nic->check_link) { err = -ENOMEM; - goto err_disable_sriov; + goto err_remove_sysfs_attr; } INIT_DELAYED_WORK(&nic->dwork, nic_poll_for_link); @@ -1248,6 +1308,8 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; +err_remove_sysfs_attr: + device_remove_file(dev, &dev_attr_sriov_sqs_assignment); err_disable_sriov: if (nic->flags & NIC_SRIOV_ENABLED) { nic_put_vf_pdev(nic); @@ -1266,6 +1328,9 @@ err_disable_device: static void nic_remove(struct pci_dev *pdev) { struct nicpf *nic = pci_get_drvdata(pdev); + struct device *dev = &pdev->dev; + + device_remove_file(dev, &dev_attr_sriov_sqs_assignment); if (nic->flags & NIC_SRIOV_ENABLED) { nic_put_vf_pdev(nic);