From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by dpdk.org (Postfix) with ESMTP id 8477558DD for ; Tue, 7 Apr 2015 23:21:06 +0200 (CEST) Received: by pdea3 with SMTP id a3so91559068pde.3 for ; Tue, 07 Apr 2015 14:21:06 -0700 (PDT) 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=EHXKxxR7Eo2gejFChk4LUdRNcheXcDmF0qhtDhp0AEs=; b=MD9TGfykV+HlF2d8uJHSlr7d5yBOLVa9NxNGEVL7zNVQgREQEioLy5+g4vpgVS7BTh IspR1Ima0Sgkognaf2hxZY+WONIguvdOL4c6gVMixQvw1LFOiggP3t9Q0C22S81Al8Jj qMVo0J8R1afO6H0Rx2x7YU/nxi2C4u4tSaupcC7oUY5n6JYNWBKBEDK+BZNlgbC2XPyM O7MM1WonoDZnlXzPLsAumQ5wWp9NO8uZ5cnH5anMbYfYYGXqCR0G+I+yLD/4m+Jn+DY4 kxX0+PhdIn+EtEOuevoR6mSRT4sMjmMWY/AMsF7R5nTfAFn2m2gO1l+/TWn0TxvCLMGg thWA== X-Gm-Message-State: ALoCoQm9+o2g4bVHn1jT6TB4kMd/FVEEvfgScQc45HHUGWK2dXadvmgnewkCMSRYD4NiuxB8Lznj X-Received: by 10.66.249.101 with SMTP id yt5mr15137022pac.116.1428441665924; Tue, 07 Apr 2015 14:21:05 -0700 (PDT) Received: from urahara.brocade.com (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id j2sm9020328pdn.44.2015.04.07.14.21.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Apr 2015 14:21:05 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Tue, 7 Apr 2015 14:21:02 -0700 Message-Id: <1428441663-3825-5-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1428441663-3825-1-git-send-email-stephen@networkplumber.org> References: <1428441663-3825-1-git-send-email-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 5/6] test: put dev_ops in private X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2015 21:21:07 -0000 The test PMD uses a special type of eth_dev_ops to test features. Rather allocating this separately, just put in the private data area. This allows for next change to make dev_ops const. Signed-off-by: Stephen Hemminger --- v2 -- split into separate patch and put dev_ops in private app/test/virtual_pmd.c | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index 1f4da96..3ae8c90 100644 --- a/app/test/virtual_pmd.c +++ b/app/test/virtual_pmd.c @@ -45,6 +45,7 @@ static const char *virtual_ethdev_driver_name = "Virtual PMD"; struct virtual_ethdev_private { + struct eth_dev_ops dev_ops; struct rte_eth_stats eth_stats; struct rte_ring *rx_queue; @@ -262,61 +263,67 @@ static struct eth_dev_ops virtual_ethdev_default_dev_ops = { void virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) - vrtl_eth_dev->dev_ops->dev_start = virtual_ethdev_start_success; + dev_ops->dev_start = virtual_ethdev_start_success; else - vrtl_eth_dev->dev_ops->dev_start = virtual_ethdev_start_fail; + dev_ops->dev_start = virtual_ethdev_start_fail; } void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) - vrtl_eth_dev->dev_ops->dev_configure = virtual_ethdev_configure_success; + dev_ops->dev_configure = virtual_ethdev_configure_success; else - vrtl_eth_dev->dev_ops->dev_configure = virtual_ethdev_configure_fail; + dev_ops->dev_configure = virtual_ethdev_configure_fail; } void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) - vrtl_eth_dev->dev_ops->rx_queue_setup = - virtual_ethdev_rx_queue_setup_success; + dev_ops->rx_queue_setup = virtual_ethdev_rx_queue_setup_success; else - vrtl_eth_dev->dev_ops->rx_queue_setup = - virtual_ethdev_rx_queue_setup_fail; + dev_ops->rx_queue_setup = virtual_ethdev_rx_queue_setup_fail; } void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) - vrtl_eth_dev->dev_ops->tx_queue_setup = - virtual_ethdev_tx_queue_setup_success; + dev_ops->tx_queue_setup = virtual_ethdev_tx_queue_setup_success; else - vrtl_eth_dev->dev_ops->tx_queue_setup = - virtual_ethdev_tx_queue_setup_fail; + dev_ops->tx_queue_setup = virtual_ethdev_tx_queue_setup_fail; } void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) - vrtl_eth_dev->dev_ops->link_update = virtual_ethdev_link_update_success; + dev_ops->link_update = virtual_ethdev_link_update_success; else - vrtl_eth_dev->dev_ops->link_update = virtual_ethdev_link_update_fail; + dev_ops->link_update = virtual_ethdev_link_update_fail; } @@ -528,7 +535,6 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, struct rte_eth_dev *eth_dev = NULL; struct eth_driver *eth_drv = NULL; struct rte_pci_driver *pci_drv = NULL; - struct eth_dev_ops *dev_ops = NULL; struct rte_pci_id *id_table = NULL; struct virtual_ethdev_private *dev_private = NULL; char name_buf[RTE_RING_NAMESIZE]; @@ -553,10 +559,6 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, if (pci_drv == NULL) goto err; - dev_ops = rte_zmalloc_socket(name, sizeof(*dev_ops), 0, socket_id); - if (dev_ops == NULL) - goto err; - id_table = rte_zmalloc_socket(name, sizeof(*id_table), 0, socket_id); if (id_table == NULL) goto err; @@ -618,11 +620,9 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, eth_dev->data->dev_private = dev_private; - eth_dev->dev_ops = dev_ops; - /* Copy default device operation functions */ - memcpy(eth_dev->dev_ops, &virtual_ethdev_default_dev_ops, - sizeof(*eth_dev->dev_ops)); + dev_private->dev_ops = virtual_ethdev_default_dev_ops; + eth_dev->dev_ops = &dev_private->dev_ops; eth_dev->pci_dev = pci_dev; eth_dev->pci_dev->driver = ð_drv->pci_drv; @@ -638,7 +638,6 @@ err: rte_free(pci_dev); rte_free(pci_drv); rte_free(eth_drv); - rte_free(dev_ops); rte_free(id_table); rte_free(dev_private); -- 2.1.4