From patchwork Wed Feb 17 14:20:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 10571 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id ECFD1C338; Wed, 17 Feb 2016 15:21:08 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id A4237C336 for ; Wed, 17 Feb 2016 15:21:07 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 17 Feb 2016 06:20:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,460,1449561600"; d="scan'208";a="904728274" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 17 Feb 2016 06:20:42 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u1HEKgQA019050; Wed, 17 Feb 2016 14:20:42 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u1HEKfHF014419; Wed, 17 Feb 2016 14:20:41 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u1HEKfcj014415; Wed, 17 Feb 2016 14:20:41 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Wed, 17 Feb 2016 14:20:16 +0000 Message-Id: <1455718817-14171-3-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1455718817-14171-1-git-send-email-ferruh.yigit@intel.com> References: <1455718817-14171-1-git-send-email-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 2/3] app/test: use ethdev helper functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use rte_eth_by_port(), rte_eth_private_by_port(), rte_eth_private_by_dev() helper functions. Signed-off-by: Ferruh Yigit --- app/test/test_link_bonding.c | 35 +++++++++++++++++------------- app/test/virtual_pmd.c | 51 +++++++++++++++++++------------------------- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 7cbc289..f2e364b 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -4567,6 +4567,8 @@ test_alb_change_mac_in_reply_sent(void) struct ether_addr bond_mac, client_mac; struct ether_addr *slave_mac1, *slave_mac2; + struct rte_eth_dev *dev; + TEST_ASSERT_SUCCESS( initialize_bonded_device_with_slaves(BONDING_MODE_ALB, 0, TEST_ALB_SLAVE_COUNT, 1), @@ -4581,9 +4583,8 @@ test_alb_change_mac_in_reply_sent(void) MAX_PKT_BURST); } - ether_addr_copy( - rte_eth_devices[test_params->bonded_port_id].data->mac_addrs, - &bond_mac); + dev = rte_eth_by_port(test_params->bonded_port_id); + ether_addr_copy(dev->data->mac_addrs, &bond_mac); /* * Generating four packets with different mac and ip addresses and sending @@ -4629,10 +4630,10 @@ test_alb_change_mac_in_reply_sent(void) ARP_OP_REPLY); rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt, 1); - slave_mac1 = - rte_eth_devices[test_params->slave_port_ids[0]].data->mac_addrs; - slave_mac2 = - rte_eth_devices[test_params->slave_port_ids[1]].data->mac_addrs; + dev = rte_eth_by_port(test_params->slave_port_ids[0]); + slave_mac1 = dev->data->mac_addrs; + dev = rte_eth_by_port(test_params->slave_port_ids[1]); + slave_mac2 = dev->data->mac_addrs; /* * Checking if packets are properly distributed on bonding ports. Packets @@ -4681,6 +4682,8 @@ test_alb_reply_from_client(void) struct ether_addr bond_mac, client_mac; struct ether_addr *slave_mac1, *slave_mac2; + struct rte_eth_dev *dev; + TEST_ASSERT_SUCCESS( initialize_bonded_device_with_slaves(BONDING_MODE_ALB, 0, TEST_ALB_SLAVE_COUNT, 1), @@ -4694,9 +4697,8 @@ test_alb_reply_from_client(void) MAX_PKT_BURST); } - ether_addr_copy( - rte_eth_devices[test_params->bonded_port_id].data->mac_addrs, - &bond_mac); + dev = rte_eth_by_port(test_params->bonded_port_id); + ether_addr_copy(dev->data->mac_addrs, &bond_mac); /* * Generating four packets with different mac and ip addresses and placing @@ -4753,8 +4755,10 @@ test_alb_reply_from_client(void) rte_eth_rx_burst(test_params->bonded_port_id, 0, pkts_sent, MAX_PKT_BURST); rte_eth_tx_burst(test_params->bonded_port_id, 0, NULL, 0); - slave_mac1 = rte_eth_devices[test_params->slave_port_ids[0]].data->mac_addrs; - slave_mac2 = rte_eth_devices[test_params->slave_port_ids[1]].data->mac_addrs; + dev = rte_eth_by_port(test_params->slave_port_ids[0]); + slave_mac1 = dev->data->mac_addrs; + dev = rte_eth_by_port(test_params->slave_port_ids[1]); + slave_mac2 = dev->data->mac_addrs; /* * Checking if update ARP packets were properly send on slave ports. @@ -4808,6 +4812,8 @@ test_alb_receive_vlan_reply(void) struct ether_addr bond_mac, client_mac; + struct rte_eth_dev *dev; + TEST_ASSERT_SUCCESS( initialize_bonded_device_with_slaves(BONDING_MODE_ALB, 0, TEST_ALB_SLAVE_COUNT, 1), @@ -4821,9 +4827,8 @@ test_alb_receive_vlan_reply(void) MAX_PKT_BURST); } - ether_addr_copy( - rte_eth_devices[test_params->bonded_port_id].data->mac_addrs, - &bond_mac); + dev = rte_eth_by_port(test_params->bonded_port_id); + ether_addr_copy(dev->data->mac_addrs, &bond_mac); /* * Generating packet with double VLAN header and placing it in the rx queue. diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index a538c8a..b1af805 100644 --- a/app/test/virtual_pmd.c +++ b/app/test/virtual_pmd.c @@ -263,8 +263,8 @@ static const 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 *dev = &rte_eth_devices[port_id]; - struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) @@ -277,8 +277,8 @@ virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success) void virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *dev = &rte_eth_devices[port_id]; - struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) @@ -290,8 +290,8 @@ virtual_ethdev_configure_fn_set_success(uint8_t port_id, uint8_t success) void virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *dev = &rte_eth_devices[port_id]; - struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) @@ -303,8 +303,8 @@ virtual_ethdev_rx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) void virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *dev = &rte_eth_devices[port_id]; - struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) @@ -316,8 +316,8 @@ virtual_ethdev_tx_queue_setup_fn_set_success(uint8_t port_id, uint8_t success) void virtual_ethdev_link_update_fn_set_success(uint8_t port_id, uint8_t success) { - struct rte_eth_dev *dev = &rte_eth_devices[port_id]; - struct virtual_ethdev_private *dev_private = dev->data->dev_private; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); struct eth_dev_ops *dev_ops = &dev_private->dev_ops; if (success) @@ -332,15 +332,13 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, struct rte_mbuf **bufs, uint16_t nb_pkts) { - struct rte_eth_dev *vrtl_eth_dev; struct virtual_ethdev_queue *pq_map; struct virtual_ethdev_private *dev_private; int rx_count, i; pq_map = (struct virtual_ethdev_queue *)queue; - vrtl_eth_dev = &rte_eth_devices[pq_map->port_id]; - dev_private = vrtl_eth_dev->data->dev_private; + dev_private = rte_eth_private_by_port(pq_map->port_id); rx_count = rte_ring_dequeue_burst(dev_private->rx_queue, (void **) bufs, nb_pkts); @@ -374,7 +372,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, int i; - vrtl_eth_dev = &rte_eth_devices[tx_q->port_id]; + vrtl_eth_dev = rte_eth_by_port(tx_q->port_id); dev_private = vrtl_eth_dev->data->dev_private; if (!vrtl_eth_dev->data->dev_link.link_status) @@ -397,15 +395,13 @@ static uint16_t virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { - struct rte_eth_dev *vrtl_eth_dev = NULL; struct virtual_ethdev_queue *tx_q = NULL; struct virtual_ethdev_private *dev_private = NULL; int i; tx_q = (struct virtual_ethdev_queue *)queue; - vrtl_eth_dev = &rte_eth_devices[tx_q->port_id]; - dev_private = vrtl_eth_dev->data->dev_private; + dev_private = rte_eth_private_by_port(tx_q->port_id); if (dev_private->tx_burst_fail_count < nb_pkts) { int successfully_txd = nb_pkts - dev_private->tx_burst_fail_count; @@ -432,7 +428,7 @@ virtual_ethdev_tx_burst_fail(void *queue, struct rte_mbuf **bufs, void virtual_ethdev_rx_burst_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 *vrtl_eth_dev = rte_eth_by_port(port_id); if (success) vrtl_eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success; @@ -445,7 +441,7 @@ void virtual_ethdev_tx_burst_fn_set_success(uint8_t port_id, uint8_t success) { struct virtual_ethdev_private *dev_private = NULL; - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *vrtl_eth_dev = rte_eth_by_port(port_id); dev_private = vrtl_eth_dev->data->dev_private; @@ -461,18 +457,17 @@ void virtual_ethdev_tx_burst_fn_set_tx_pkt_fail_count(uint8_t port_id, uint8_t packet_fail_count) { - struct virtual_ethdev_private *dev_private = NULL; - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private; - dev_private = vrtl_eth_dev->data->dev_private; + dev_private = rte_eth_private_by_port(port_id); dev_private->tx_burst_fail_count = packet_fail_count; } void virtual_ethdev_set_link_status(uint8_t port_id, uint8_t link_status) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *vrtl_eth_dev = rte_eth_by_port(port_id); vrtl_eth_dev->data->dev_link.link_status = link_status; } @@ -481,7 +476,7 @@ void virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id, uint8_t link_status) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct rte_eth_dev *vrtl_eth_dev = rte_eth_by_port(port_id); vrtl_eth_dev->data->dev_link.link_status = link_status; @@ -492,9 +487,8 @@ int virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, struct rte_mbuf **pkt_burst, int burst_length) { - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; struct virtual_ethdev_private *dev_private = - vrtl_eth_dev->data->dev_private; + rte_eth_private_by_port(port_id); return rte_ring_enqueue_burst(dev_private->rx_queue, (void **)pkt_burst, burst_length); @@ -504,10 +498,9 @@ int virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, struct rte_mbuf **pkt_burst, int burst_length) { - struct virtual_ethdev_private *dev_private; - struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id]; + struct virtual_ethdev_private *dev_private = + rte_eth_private_by_port(port_id); - dev_private = vrtl_eth_dev->data->dev_private; return rte_ring_dequeue_burst(dev_private->tx_queue, (void **)pkt_burst, burst_length); }