From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 407C429D6 for ; Fri, 9 Dec 2016 09:54:48 +0100 (CET) Received: by mail-wm0-f43.google.com with SMTP id t79so16637989wmt.0 for ; Fri, 09 Dec 2016 00:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weka-io.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:organization:user-agent :mime-version:content-transfer-encoding; bh=CIO9G5PsDFFtb4q9uhok4/kmK1I4AxQjd1rE2tj4j/I=; b=a/AEkMAGulgMR2yn+P6jcS9ey5MIeMr343yPjkspiIznpBX//epqTXZ6p5SUt/8lJa /JgKIdHpXCVMnHIn1Nvb7EMt4F0BOu/rSVuwEGbL5R9sDsIprLFfV7DFV8Xq4RHKK4oE wsxv97M/uxZsYiffBmxQBgcqm/ptLksVciP804AV7CclQ9piGrcq7mVMUPN1b52VFhWB OUFx31BpzaTBz/iS25PBV3Zxff5AgP2y/4AJ2C1orNKBDFzxxJmrjzVheFu1PZWxT0Qy 8aA08y4eozNJgnP0okvbgXAILM9758bkSI1/6U+x4iEdMH3SF75lM6MoFzV0uBy1ZUq4 nWFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding; bh=CIO9G5PsDFFtb4q9uhok4/kmK1I4AxQjd1rE2tj4j/I=; b=gMHVNbL1A9VxwmDJKyx/qM94SQsWeADqL7oBAbLE2jhRY9VWW8kyABbew9ErZP7Npj wPcxllUDObEpcWF83lFnPvGTqDlnkMiXAcA3d91nxByksbWIm0jQu5hGDbSARQXLVdtc r7bUhgBYU1TGFYuMBspEJUPOAsh0ZC+7NiwnHFVISrcEng/nq+lLuskJDs05JgtFzamH ++xNZQFQkQM6VctrG4bvONoChZJm9kNDfQwPCAJLO+nQ0rtyZkN9bLN9oEiOQdHKgnm4 qEpBhcz62MWMewxYCmt3QDr5mX6EzRlRs8ZvxQAA/PirzulXxCuuPHRHqPcS/0lBiOTO aHTA== X-Gm-Message-State: AKaTC00A1Eyoca93ZNnuInwWxlAM801KjD5eUGyfKzJ3MZAYISHCQDiUT6da1BXsrQgIyw== X-Received: by 10.28.94.76 with SMTP id s73mr2194575wmb.107.1481273687903; Fri, 09 Dec 2016 00:54:47 -0800 (PST) Received: from polaris.localnet (bzq-84-109-69-99.cablep.bezeqint.net. [84.109.69.99]) by smtp.gmail.com with ESMTPSA id k11sm19376217wmf.24.2016.12.09.00.54.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 00:54:47 -0800 (PST) From: Gregory Etelson To: dev@dpdk.org, users@dpdk.org Date: Fri, 09 Dec 2016 10:54:39 +0200 Message-ID: <3355891.l3I590SjcV@polaris> Organization: Weka.IO User-Agent: KMail/5.3.2 (Linux/4.8.6-201.fc24.x86_64; KDE/5.27.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-users] IGB_UIO: PCI Resources Management X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Dec 2016 08:54:48 -0000 Hello, IGB_UIO driver does not close port PCI activities after DPDK process exits. DPDK API provides rte_eth_dev_close() to manage port PCI, but it can be skipped if process receives SIGKILL signal The patches below provide IGB_UIO release callback and IXGBEVF release function With the patches, each time DPDK process terminates, UIO release callback will trigger port PCI close. On the down side, patched IGB_UIO can be bound to a single adapter type Regards, Gregory diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index df41e45..97b8501 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -170,6 +170,16 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info) return IRQ_HANDLED; } +static int +igbuio_pci_release(struct uio_info *info, struct inode *inode) +{ + extern int ixgbevf_uio_release(struct pci_dev *pdev, u8 __iomem *hw_addr); + int ret; + struct rte_uio_pci_dev *udev = info->priv; + ret = ixgbevf_uio_release(udev->pdev, info->mem[0].internal_addr); + return 0; +} + #ifdef CONFIG_XEN_DOM0 static int igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma) @@ -368,6 +378,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) udev->info.version = "0.1"; udev->info.handler = igbuio_pci_irqhandler; udev->info.irqcontrol = igbuio_pci_irqcontrol; + udev->info.release = igbuio_pci_release; #ifdef CONFIG_XEN_DOM0 /* check if the driver run on Xen Dom0 */ if (xen_initial_domain()) diff --git a/src/ixgbevf_main.c b/src/ixgbevf_main.c index c5a922f..b96d9f0 100644 --- a/src/ixgbevf_main.c +++ b/src/ixgbevf_main.c @@ -3002,6 +3002,39 @@ static void ixgbevf_clear_interrupt_scheme(struct ixgbevf_adapter *adapter) ixgbevf_reset_interrupt_capability(adapter); } +int ixgbevf_uio_release(struct pci_dev *pdev, u8 __iomem *hw_addr) +{ + int err; + struct ixgbe_hw __hw; + struct ixgbe_hw *hw = &__hw; + + if (!hw_addr) { + dev_warn(&pdev->dev, "ixgbevf_uio_release: no HW addr. Bailing out\n"); + } + + memset(hw, 0, sizeof(*hw)); + hw->hw_addr = hw_addr; + + /* PCI config space info */ + hw->vendor_id = pdev->vendor; + hw->device_id = pdev->device; + pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); + hw->subsystem_vendor_id = pdev->subsystem_vendor; + hw->subsystem_device_id = pdev->subsystem_device; + + ixgbe_init_ops_vf(hw); + hw->mbx.ops.init_params(hw); + + /* assume legacy case in which PF would only give VF 2 queues */ + hw->mac.max_tx_queues = 2; + hw->mac.max_rx_queues = 2; + + err = hw->mac.ops.stop_adapter(hw); + dev_info(&pdev->dev, "ixgbevf_uio_release: UIO adapter stopped\n"); + return err; +} +EXPORT_SYMBOL(ixgbevf_uio_release); + /** * ixgbevf_sw_init - Initialize general software structures * (struct ixgbevf_adapter)