From patchwork Fri Apr 12 12:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 52705 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6C701B1CE; Fri, 12 Apr 2019 14:29:29 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80070.outbound.protection.outlook.com [40.107.8.70]) by dpdk.org (Postfix) with ESMTP id 3820C1B10D for ; Fri, 12 Apr 2019 14:29:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wbrEkz04S1mDOd2tZmXNaN98LgYcyXVsJJwc12B769Q=; b=P10w30D99pRemwerKOsBIvdQCdNeJiw/6QIKqqtUiOG5GJqucWkRYf88ziBiCmh4OhslMhWYsEuIBv3WLpsjcM7ZlZriFNDt2TSeg+JGd/mdsMQhvAezJhAO7g65NAWHXc6Wl6eDTukNI6q79zIaI8JBPRauitNnzhf+Ln3zatg= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6702.eurprd04.prod.outlook.com (20.179.235.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.17; Fri, 12 Apr 2019 12:29:02 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1792.016; Fri, 12 Apr 2019 12:29:02 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH v4 07/13] net/enetc: remove forward declarations Thread-Index: AQHU8StPATlkdRk51kmW+0L3x88vNA== Date: Fri, 12 Apr 2019 12:29:02 +0000 Message-ID: <20190412122840.1908-8-g.singh@nxp.com> References: <20190412105105.24351-1-g.singh@nxp.com> <20190412122840.1908-1-g.singh@nxp.com> In-Reply-To: <20190412122840.1908-1-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0029.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::15) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 2.19.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.0.8] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5b4e72c8-2f99-4a08-bebe-08d6bf427202 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VE1PR04MB6702; x-ms-traffictypediagnostic: VE1PR04MB6702: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(376002)(366004)(39860400002)(346002)(199004)(189003)(476003)(102836004)(97736004)(2616005)(5660300002)(52116002)(6486002)(76176011)(36756003)(11346002)(486006)(446003)(26005)(6506007)(386003)(256004)(14444005)(186003)(2906002)(4326008)(8936002)(50226002)(3846002)(14454004)(53936002)(86362001)(105586002)(478600001)(66066001)(106356001)(6116002)(1076003)(72206003)(81166006)(316002)(110136005)(81156014)(68736007)(25786009)(305945005)(7736002)(99286004)(2501003)(8676002)(71190400001)(71200400001)(6436002)(6512007); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6702; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: GqbiLuBmRivLTMZw/eVYfb0HqZc5aC3WLH4HDaImfezYM4erZI4WQDectKsOC8R0cw5cG8Ubo9sj0hqm+Fgvz6AtdNdXLj8i8x3zuWunoIo4SWWOSwfNczbpSwjK6Cyij5ZQr+b0qc+UbVdAvWehiJMXw8lpemdXGU2sV6sBlzqRv4sQNcuI2mB6GPHzEzwBVB+WACW+cJEG0hMOkGW8XkoqY/T0A9T0/r2DhALBbRYIw8GX6KTMoOb9dEir0vhmACrlQ+qI2sIT1vWiuiwMGzCLexkr5gG1Il0k+NIKUl9lTLQB0Pbd55OhnLCiJzzdFxf2WZGjzDGHd+1+CZtrSd+C/zpXfbzJGkGKmUZHqvyLL1sCaxws9WWS6Ro5G06XAxthGTWG/JjTefmKwAL/zQGgdSPKBSJCqZEmdXWGTt0= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b4e72c8-2f99-4a08-bebe-08d6bf427202 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 12:29:02.4746 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6702 Subject: [dpdk-dev] [PATCH v4 07/13] net/enetc: remove forward declarations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Remove unneeded forward declarations and re-order the code. Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc_ethdev.c | 237 ++++++++++++++----------------- 1 file changed, 107 insertions(+), 130 deletions(-) diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 2d8c4e604..d0f9e2b35 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -10,115 +10,6 @@ int enetc_logtype_pmd; -/* Functions Prototypes */ -static int enetc_dev_configure(struct rte_eth_dev *dev); -static int enetc_dev_start(struct rte_eth_dev *dev); -static void enetc_dev_stop(struct rte_eth_dev *dev); -static void enetc_dev_close(struct rte_eth_dev *dev); -static void enetc_dev_infos_get(struct rte_eth_dev *dev, - struct rte_eth_dev_info *dev_info); -static int enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete); -static int enetc_hardware_init(struct enetc_eth_hw *hw); -static int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, - uint16_t nb_rx_desc, unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mb_pool); -static void enetc_rx_queue_release(void *rxq); -static int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, - uint16_t nb_tx_desc, unsigned int socket_id, - const struct rte_eth_txconf *tx_conf); -static void enetc_tx_queue_release(void *txq); -static const uint32_t *enetc_supported_ptypes_get(struct rte_eth_dev *dev); -static int enetc_stats_get(struct rte_eth_dev *dev, - struct rte_eth_stats *stats); -static void enetc_stats_reset(struct rte_eth_dev *dev); - -/* - * The set of PCI devices this driver supports - */ -static const struct rte_pci_id pci_id_enetc_map[] = { - { RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) }, - { RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) }, - { .vendor_id = 0, /* sentinel */ }, -}; - -/* Features supported by this driver */ -static const struct eth_dev_ops enetc_ops = { - .dev_configure = enetc_dev_configure, - .dev_start = enetc_dev_start, - .dev_stop = enetc_dev_stop, - .dev_close = enetc_dev_close, - .link_update = enetc_link_update, - .stats_get = enetc_stats_get, - .stats_reset = enetc_stats_reset, - .dev_infos_get = enetc_dev_infos_get, - .rx_queue_setup = enetc_rx_queue_setup, - .rx_queue_release = enetc_rx_queue_release, - .tx_queue_setup = enetc_tx_queue_setup, - .tx_queue_release = enetc_tx_queue_release, - .dev_supported_ptypes_get = enetc_supported_ptypes_get, -}; - -/** - * Initialisation of the enetc device - * - * @param eth_dev - * - Pointer to the structure rte_eth_dev - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static int -enetc_dev_init(struct rte_eth_dev *eth_dev) -{ - int error = 0; - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - struct enetc_eth_hw *hw = - ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - - PMD_INIT_FUNC_TRACE(); - eth_dev->dev_ops = &enetc_ops; - eth_dev->rx_pkt_burst = &enetc_recv_pkts; - eth_dev->tx_pkt_burst = &enetc_xmit_pkts; - - /* Retrieving and storing the HW base address of device */ - hw->hw.reg = (void *)pci_dev->mem_resource[0].addr; - hw->device_id = pci_dev->id.device_id; - - error = enetc_hardware_init(hw); - if (error != 0) { - ENETC_PMD_ERR("Hardware initialization failed"); - return -1; - } - - /* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0); - if (!eth_dev->data->mac_addrs) { - ENETC_PMD_ERR("Failed to allocate %d bytes needed to " - "store MAC addresses", - ETHER_ADDR_LEN * 1); - error = -ENOMEM; - return -1; - } - - /* Copy the permanent MAC address */ - ether_addr_copy((struct ether_addr *)hw->mac.addr, - ð_dev->data->mac_addrs[0]); - - ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x", - eth_dev->data->port_id, pci_dev->id.vendor_id, - pci_dev->id.device_id); - return 0; -} - -static int -enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) -{ - PMD_INIT_FUNC_TRACE(); - return 0; -} - static int enetc_dev_configure(struct rte_eth_dev *dev __rte_unused) { @@ -179,27 +70,6 @@ enetc_dev_stop(struct rte_eth_dev *dev) val & (~(ENETC_PM0_TX_EN | ENETC_PM0_RX_EN))); } -static void -enetc_dev_close(struct rte_eth_dev *dev) -{ - uint16_t i; - - PMD_INIT_FUNC_TRACE(); - enetc_dev_stop(dev); - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - enetc_rx_queue_release(dev->data->rx_queues[i]); - dev->data->rx_queues[i] = NULL; - } - dev->data->nb_rx_queues = 0; - - for (i = 0; i < dev->data->nb_tx_queues; i++) { - enetc_tx_queue_release(dev->data->tx_queues[i]); - dev->data->tx_queues[i] = NULL; - } - dev->data->nb_tx_queues = 0; -} - static const uint32_t * enetc_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused) { @@ -648,6 +518,113 @@ enetc_stats_reset(struct rte_eth_dev *dev) enetc_port_wr(enetc_hw, ENETC_PM0_STAT_CONFIG, ENETC_CLEAR_STATS); } +static void +enetc_dev_close(struct rte_eth_dev *dev) +{ + uint16_t i; + + PMD_INIT_FUNC_TRACE(); + enetc_dev_stop(dev); + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + enetc_rx_queue_release(dev->data->rx_queues[i]); + dev->data->rx_queues[i] = NULL; + } + dev->data->nb_rx_queues = 0; + + for (i = 0; i < dev->data->nb_tx_queues; i++) { + enetc_tx_queue_release(dev->data->tx_queues[i]); + dev->data->tx_queues[i] = NULL; + } + dev->data->nb_tx_queues = 0; +} + +/* + * The set of PCI devices this driver supports + */ +static const struct rte_pci_id pci_id_enetc_map[] = { + { RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID) }, + { RTE_PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_VF) }, + { .vendor_id = 0, /* sentinel */ }, +}; + +/* Features supported by this driver */ +static const struct eth_dev_ops enetc_ops = { + .dev_configure = enetc_dev_configure, + .dev_start = enetc_dev_start, + .dev_stop = enetc_dev_stop, + .dev_close = enetc_dev_close, + .link_update = enetc_link_update, + .stats_get = enetc_stats_get, + .stats_reset = enetc_stats_reset, + .dev_infos_get = enetc_dev_infos_get, + .rx_queue_setup = enetc_rx_queue_setup, + .rx_queue_release = enetc_rx_queue_release, + .tx_queue_setup = enetc_tx_queue_setup, + .tx_queue_release = enetc_tx_queue_release, + .dev_supported_ptypes_get = enetc_supported_ptypes_get, +}; + +/** + * Initialisation of the enetc device + * + * @param eth_dev + * - Pointer to the structure rte_eth_dev + * + * @return + * - On success, zero. + * - On failure, negative value. + */ +static int +enetc_dev_init(struct rte_eth_dev *eth_dev) +{ + int error = 0; + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + struct enetc_eth_hw *hw = + ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + + PMD_INIT_FUNC_TRACE(); + eth_dev->dev_ops = &enetc_ops; + eth_dev->rx_pkt_burst = &enetc_recv_pkts; + eth_dev->tx_pkt_burst = &enetc_xmit_pkts; + + /* Retrieving and storing the HW base address of device */ + hw->hw.reg = (void *)pci_dev->mem_resource[0].addr; + hw->device_id = pci_dev->id.device_id; + + error = enetc_hardware_init(hw); + if (error != 0) { + ENETC_PMD_ERR("Hardware initialization failed"); + return -1; + } + + /* Allocate memory for storing MAC addresses */ + eth_dev->data->mac_addrs = rte_zmalloc("enetc_eth", ETHER_ADDR_LEN, 0); + if (!eth_dev->data->mac_addrs) { + ENETC_PMD_ERR("Failed to allocate %d bytes needed to " + "store MAC addresses", + ETHER_ADDR_LEN * 1); + error = -ENOMEM; + return -1; + } + + /* Copy the permanent MAC address */ + ether_addr_copy((struct ether_addr *)hw->mac.addr, + ð_dev->data->mac_addrs[0]); + + ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x", + eth_dev->data->port_id, pci_dev->id.vendor_id, + pci_dev->id.device_id); + return 0; +} + +static int +enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) +{ + PMD_INIT_FUNC_TRACE(); + return 0; +} + static int enetc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev)