diff mbox

[dpdk-dev,3/3] bonding: use ethdev helper functions

Message ID 1455718817-14171-4-git-send-email-ferruh.yigit@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers show

Commit Message

Ferruh Yigit Feb. 17, 2016, 2:20 p.m. UTC
Use rte_eth_by_port(), rte_eth_private_by_port(),
rte_eth_private_by_dev() helper functions.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 10 ++--
 drivers/net/bonding/rte_eth_bond_api.c    | 76 +++++++++++++++----------------
 drivers/net/bonding/rte_eth_bond_args.c   | 13 ++++--
 drivers/net/bonding/rte_eth_bond_pmd.c    | 47 +++++++++++--------
 4 files changed, 81 insertions(+), 65 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index b3b30f6..18402c2 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -854,6 +854,7 @@  bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 	uint32_t total_tx_desc;
 	struct bond_tx_queue *bd_tx_q;
 	uint16_t q_id;
+	struct rte_eth_dev *dev;
 
 	/* Given slave mus not be in active list */
 	RTE_VERIFY(find_slave_by_id(internals->active_slaves,
@@ -882,7 +883,8 @@  bond_mode_8023ad_activate_slave(struct rte_eth_dev *bond_dev, uint8_t slave_id)
 
 	RTE_VERIFY(port->rx_ring == NULL);
 	RTE_VERIFY(port->tx_ring == NULL);
-	socket_id = rte_eth_devices[slave_id].data->numa_node;
+	dev = rte_eth_by_port(slave_id);
+	socket_id = dev->data->numa_node;
 
 	element_size = sizeof(struct slow_protocol_frame) + sizeof(struct rte_mbuf)
 				+ RTE_PKTMBUF_HEADROOM;
@@ -1153,7 +1155,7 @@  rte_eth_bond_8023ad_conf_get(uint8_t port_id,
 	if (conf == NULL)
 		return -EINVAL;
 
-	bond_dev = &rte_eth_devices[port_id];
+	bond_dev = rte_eth_by_port(port_id);
 	bond_mode_8023ad_conf_get(bond_dev, conf);
 	return 0;
 }
@@ -1182,7 +1184,7 @@  rte_eth_bond_8023ad_setup(uint8_t port_id,
 		}
 	}
 
-	bond_dev = &rte_eth_devices[port_id];
+	bond_dev = rte_eth_by_port(port_id);
 	bond_mode_8023ad_setup(bond_dev, conf);
 
 	return 0;
@@ -1200,7 +1202,7 @@  rte_eth_bond_8023ad_slave_info(uint8_t port_id, uint8_t slave_id,
 			rte_eth_bond_mode_get(port_id) != BONDING_MODE_8023AD)
 		return -EINVAL;
 
-	bond_dev = &rte_eth_devices[port_id];
+	bond_dev = rte_eth_by_port(port_id);
 
 	internals = bond_dev->data->dev_private;
 	if (find_slave_by_id(internals->active_slaves,
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 8a000c8..c61ad01 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -63,7 +63,7 @@  valid_bonded_port_id(uint8_t port_id)
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
 
-	return check_for_bonded_ethdev(&rte_eth_devices[port_id]);
+	return check_for_bonded_ethdev(rte_eth_by_port(port_id));
 }
 
 int
@@ -74,7 +74,7 @@  valid_slave_port_id(uint8_t port_id)
 		return -1;
 
 	/* Verify that port_id refers to a non bonded port */
-	if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)
+	if (check_for_bonded_ethdev(rte_eth_by_port(port_id)) == 0)
 		return -1;
 
 	return 0;
@@ -318,14 +318,14 @@  __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (valid_slave_port_id(slave_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+	bonded_eth_dev = rte_eth_by_port(bonded_port_id);
 	internals = bonded_eth_dev->data->dev_private;
 
 	/* Verify that new slave device is not already a slave of another
 	 * bonded device */
 	for (i = rte_eth_dev_count()-1; i >= 0; i--) {
-		if (check_for_bonded_ethdev(&rte_eth_devices[i]) == 0) {
-			temp_internals = rte_eth_devices[i].data->dev_private;
+		if (check_for_bonded_ethdev(rte_eth_by_port(i)) == 0) {
+			temp_internals = rte_eth_private_by_port(i);
 
 			for (j = 0; j < temp_internals->slave_count; j++) {
 				/* Device already a slave of a bonded device */
@@ -338,7 +338,7 @@  __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 		}
 	}
 
-	slave_eth_dev = &rte_eth_devices[slave_port_id];
+	slave_eth_dev = rte_eth_by_port(slave_port_id);
 
 	/* Add slave details to bonded device */
 	slave_add(internals, slave_eth_dev);
@@ -437,7 +437,6 @@  __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 int
 rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
-	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
 
 	int retval;
@@ -446,8 +445,7 @@  rte_eth_bond_slave_add(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	rte_spinlock_lock(&internals->lock);
 
@@ -463,14 +461,15 @@  __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
 	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
+	struct rte_eth_dev *dev;
 
 	int i, slave_idx;
 
 	if (valid_slave_port_id(slave_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
+	bonded_eth_dev = rte_eth_by_port(bonded_port_id);
+	internals = rte_eth_private_by_dev(bonded_eth_dev);
 
 	/* first remove from active slave list */
 	slave_idx = find_slave_by_id(internals->active_slaves,
@@ -495,15 +494,15 @@  __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	/* Un-register link status change callback with bonded device pointer as
 	 * argument*/
+	dev = rte_eth_by_port(bonded_port_id);
 	rte_eth_dev_callback_unregister(slave_port_id, RTE_ETH_EVENT_INTR_LSC,
-			bond_ethdev_lsc_event_callback,
-			&rte_eth_devices[bonded_port_id].data->port_id);
+			bond_ethdev_lsc_event_callback, &dev->data->port_id);
 
 	/* Restore original MAC address of slave device */
-	mac_address_set(&rte_eth_devices[slave_port_id],
+	mac_address_set(rte_eth_by_port(slave_port_id),
 			&(internals->slaves[slave_idx].persisted_mac_addr));
 
-	slave_remove(internals, &rte_eth_devices[slave_port_id]);
+	slave_remove(internals, rte_eth_by_port(slave_port_id));
 
 	/*  first slave in the active list will be the primary by default,
 	 *  otherwise use first device in list */
@@ -518,14 +517,15 @@  __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 
 	if (internals->active_slave_count < 1) {
 		/* reset device link properties as no slaves are active */
-		link_properties_reset(&rte_eth_devices[bonded_port_id]);
+		link_properties_reset(rte_eth_by_port(bonded_port_id));
 
 		/* if no slaves are any longer attached to bonded device and MAC is not
 		 * user defined then clear MAC of bonded device as it will be reset
 		 * when a new slave is added */
+		dev = rte_eth_by_port(bonded_port_id);
 		if (internals->slave_count < 1 && !internals->user_defined_mac)
-			memset(rte_eth_devices[bonded_port_id].data->mac_addrs, 0,
-					sizeof(*(rte_eth_devices[bonded_port_id].data->mac_addrs)));
+			memset(dev->data->mac_addrs, 0,
+					sizeof(*dev->data->mac_addrs));
 	}
 	if (internals->slave_count == 0) {
 		internals->rx_offload_capa = 0;
@@ -539,15 +539,13 @@  __eth_bond_slave_remove_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 int
 rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 {
-	struct rte_eth_dev *bonded_eth_dev;
 	struct bond_dev_private *internals;
 	int retval;
 
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	rte_spinlock_lock(&internals->lock);
 
@@ -564,7 +562,7 @@  rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
+	return bond_ethdev_mode_set(rte_eth_by_port(bonded_port_id), mode);
 }
 
 int
@@ -575,7 +573,7 @@  rte_eth_bond_mode_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	return internals->mode;
 }
@@ -591,7 +589,7 @@  rte_eth_bond_primary_set(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (valid_slave_port_id(slave_port_id) != 0)
 		return -1;
 
-	internals =  rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	internals->user_defined_primary_port = 1;
 	internals->primary_port = slave_port_id;
@@ -609,7 +607,7 @@  rte_eth_bond_primary_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	if (internals->slave_count < 1)
 		return -1;
@@ -629,7 +627,7 @@  rte_eth_bond_slaves_get(uint8_t bonded_port_id, uint8_t slaves[], uint8_t len)
 	if (slaves == NULL)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	if (internals->slave_count > len)
 		return -1;
@@ -652,7 +650,7 @@  rte_eth_bond_active_slaves_get(uint8_t bonded_port_id, uint8_t slaves[],
 	if (slaves == NULL)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	if (internals->active_slave_count > len)
 		return -1;
@@ -672,8 +670,8 @@  rte_eth_bond_mac_address_set(uint8_t bonded_port_id,
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
+	bonded_eth_dev = rte_eth_by_port(bonded_port_id);
+	internals = rte_eth_private_by_dev(bonded_eth_dev);
 
 	/* Set MAC Address of Bonded Device */
 	if (mac_address_set(bonded_eth_dev, mac_addr))
@@ -697,8 +695,8 @@  rte_eth_bond_mac_address_reset(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
-	internals = bonded_eth_dev->data->dev_private;
+	bonded_eth_dev = rte_eth_by_port(bonded_port_id);
+	internals = rte_eth_private_by_dev(bonded_eth_dev);
 
 	internals->user_defined_mac = 0;
 
@@ -725,7 +723,7 @@  rte_eth_bond_xmit_policy_set(uint8_t bonded_port_id, uint8_t policy)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	switch (policy) {
 	case BALANCE_XMIT_POLICY_LAYER2:
@@ -755,7 +753,7 @@  rte_eth_bond_xmit_policy_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	return internals->balance_xmit_policy;
 }
@@ -768,7 +766,7 @@  rte_eth_bond_link_monitoring_set(uint8_t bonded_port_id, uint32_t internal_ms)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 	internals->link_status_polling_interval_ms = internal_ms;
 
 	return 0;
@@ -782,7 +780,7 @@  rte_eth_bond_link_monitoring_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	return internals->link_status_polling_interval_ms;
 }
@@ -796,7 +794,7 @@  rte_eth_bond_link_down_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 	internals->link_down_delay_ms = delay_ms;
 
 	return 0;
@@ -810,7 +808,7 @@  rte_eth_bond_link_down_prop_delay_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	return internals->link_down_delay_ms;
 }
@@ -824,7 +822,7 @@  rte_eth_bond_link_up_prop_delay_set(uint8_t bonded_port_id, uint32_t delay_ms)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 	internals->link_up_delay_ms = delay_ms;
 
 	return 0;
@@ -838,7 +836,7 @@  rte_eth_bond_link_up_prop_delay_get(uint8_t bonded_port_id)
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	internals = rte_eth_devices[bonded_port_id].data->dev_private;
+	internals = rte_eth_private_by_port(bonded_port_id);
 
 	return internals->link_up_delay_ms;
 }
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index 02ecde6..d461ead 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -55,14 +55,16 @@  static inline int
 find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
 {
 	struct rte_pci_addr *eth_pci_addr;
+	struct rte_eth_dev *dev;
 	unsigned i;
 
 	for (i = 0; i < rte_eth_dev_count(); i++) {
+		dev = rte_eth_by_port(i);
 
-		if (rte_eth_devices[i].pci_dev == NULL)
+		if (dev->pci_dev == NULL)
 			continue;
 
-		eth_pci_addr = &(rte_eth_devices[i].pci_dev->addr);
+		eth_pci_addr = &dev->pci_dev->addr;
 
 		if (pci_addr->bus == eth_pci_addr->bus &&
 			pci_addr->devid == eth_pci_addr->devid &&
@@ -76,13 +78,16 @@  find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
 static inline int
 find_port_id_by_dev_name(const char *name)
 {
+	struct rte_eth_dev *dev;
 	unsigned i;
 
 	for (i = 0; i < rte_eth_dev_count(); i++) {
-		if (rte_eth_devices[i].data == NULL)
+		dev = rte_eth_by_port(i);
+
+		if (dev->data == NULL)
 			continue;
 
-		if (strcmp(rte_eth_devices[i].data->name, name) == 0)
+		if (strcmp(dev->data->name, name) == 0)
 			return i;
 	}
 	return -1;
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index b63c886..c316fd7 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -689,7 +689,7 @@  bond_ethdev_tx_burst_tlb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct bond_dev_private *internals = bd_tx_q->dev_private;
 
 	struct rte_eth_dev *primary_port =
-			&rte_eth_devices[internals->primary_port];
+			rte_eth_by_port(internals->primary_port);
 	uint16_t num_tx_total = 0;
 	uint8_t i, j;
 
@@ -1192,7 +1192,9 @@  mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr)
 int
 mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 {
-	struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
+	struct bond_dev_private *internals =
+		rte_eth_private_by_dev(bonded_eth_dev);
+	struct rte_eth_dev *dev;
 	int i;
 
 	/* Update slave devices MAC addresses */
@@ -1204,7 +1206,8 @@  mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 	case BONDING_MODE_BALANCE:
 	case BONDING_MODE_BROADCAST:
 		for (i = 0; i < internals->slave_count; i++) {
-			if (mac_address_set(&rte_eth_devices[internals->slaves[i].port_id],
+			dev = rte_eth_by_port(internals->slaves[i].port_id);
+			if (mac_address_set(dev,
 					bonded_eth_dev->data->mac_addrs)) {
 				RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
 						internals->slaves[i].port_id);
@@ -1222,15 +1225,17 @@  mac_address_slaves_update(struct rte_eth_dev *bonded_eth_dev)
 		for (i = 0; i < internals->slave_count; i++) {
 			if (internals->slaves[i].port_id ==
 					internals->current_primary_port) {
-				if (mac_address_set(&rte_eth_devices[internals->primary_port],
+				dev = rte_eth_by_port(internals->primary_port);
+				if (mac_address_set(dev,
 						bonded_eth_dev->data->mac_addrs)) {
 					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
 							internals->current_primary_port);
 					return -1;
 				}
 			} else {
-				if (mac_address_set(
-						&rte_eth_devices[internals->slaves[i].port_id],
+				dev = rte_eth_by_port(
+						internals->slaves[i].port_id);
+				if (mac_address_set(dev,
 						&internals->slaves[i].persisted_mac_addr)) {
 					RTE_BOND_LOG(ERR, "Failed to update port Id %d MAC address",
 							internals->slaves[i].port_id);
@@ -1443,6 +1448,7 @@  slave_add(struct bond_dev_private *internals,
 {
 	struct bond_slave_details *slave_details =
 			&internals->slaves[internals->slave_count];
+	struct rte_eth_dev *dev;
 
 	slave_details->port_id = slave_eth_dev->data->port_id;
 	slave_details->last_link_status = 0;
@@ -1454,10 +1460,11 @@  slave_add(struct bond_dev_private *internals,
 
 		if (!internals->link_status_polling_enabled) {
 			internals->link_status_polling_enabled = 1;
+			dev = rte_eth_by_port(internals->port_id);
 
 			rte_eal_alarm_set(internals->link_status_polling_interval_ms * 1000,
 					bond_ethdev_slave_link_status_change_monitor,
-					(void *)&rte_eth_devices[internals->port_id]);
+					(void *)dev);
 		}
 	}
 
@@ -1490,6 +1497,7 @@  static int
 bond_ethdev_start(struct rte_eth_dev *eth_dev)
 {
 	struct bond_dev_private *internals;
+	struct rte_eth_dev *dev;
 	int i;
 
 	/* slave eth dev will be started by bonded device */
@@ -1536,8 +1544,8 @@  bond_ethdev_start(struct rte_eth_dev *eth_dev)
 
 	/* Reconfigure each slave device if starting bonded device */
 	for (i = 0; i < internals->slave_count; i++) {
-		if (slave_configure(eth_dev,
-				&(rte_eth_devices[internals->slaves[i].port_id])) != 0) {
+		dev = rte_eth_by_port(internals->slaves[i].port_id);
+		if (slave_configure(eth_dev, dev) != 0) {
 			RTE_BOND_LOG(ERR,
 					"bonded port (%d) failed to reconfigure slave device (%d)",
 					eth_dev->data->port_id, internals->slaves[i].port_id);
@@ -1730,7 +1738,7 @@  bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
 		return;
 
 	bonded_ethdev = (struct rte_eth_dev *)cb_arg;
-	internals = (struct bond_dev_private *)bonded_ethdev->data->dev_private;
+	internals = rte_eth_private_by_dev(bonded_ethdev);
 
 	if (!bonded_ethdev->data->dev_started ||
 		!internals->link_status_polling_enabled)
@@ -1746,7 +1754,8 @@  bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
 			if (!internals->slaves[i].link_status_poll_enabled)
 				continue;
 
-			slave_ethdev = &rte_eth_devices[internals->slaves[i].port_id];
+			slave_ethdev =
+				rte_eth_by_port(internals->slaves[i].port_id);
 			polling_slave_found = 1;
 
 			/* Update slave link status */
@@ -1778,7 +1787,8 @@  static int
 bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete)
 {
-	struct bond_dev_private *internals = bonded_eth_dev->data->dev_private;
+	struct bond_dev_private *internals =
+		rte_eth_private_by_dev(bonded_eth_dev);
 
 	if (!bonded_eth_dev->data->dev_started ||
 		internals->active_slave_count == 0) {
@@ -1789,7 +1799,8 @@  bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 		int i, link_up = 0;
 
 		for (i = 0; i < internals->active_slave_count; i++) {
-			slave_eth_dev = &rte_eth_devices[internals->active_slaves[i]];
+			slave_eth_dev =
+				rte_eth_by_port(internals->active_slaves[i]);
 
 			(*slave_eth_dev->dev_ops->link_update)(slave_eth_dev,
 					wait_to_complete);
@@ -1927,13 +1938,13 @@  bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 	if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
 		return;
 
-	bonded_eth_dev = &rte_eth_devices[*(uint8_t *)param];
-	slave_eth_dev = &rte_eth_devices[port_id];
+	bonded_eth_dev = rte_eth_by_port(*(uint16_t *)param);
+	slave_eth_dev = rte_eth_by_port(port_id);
 
 	if (check_for_bonded_ethdev(bonded_eth_dev))
 		return;
 
-	internals = bonded_eth_dev->data->dev_private;
+	internals = rte_eth_private_by_dev(bonded_eth_dev);
 
 	/* If the device isn't started don't handle interrupts */
 	if (!bonded_eth_dev->data->dev_started)
@@ -2216,7 +2227,7 @@  bond_init(const char *name, const char *params)
 				"socket %u.\n",	name, bonding_mode, socket_id);
 		goto parse_error;
 	}
-	internals = rte_eth_devices[port_id].data->dev_private;
+	internals = rte_eth_private_by_port(port_id);
 	internals->kvlist = kvlist;
 
 	RTE_LOG(INFO, EAL, "Create bonded device %s on port %d in mode %u on "
@@ -2253,7 +2264,7 @@  static int
 bond_ethdev_configure(struct rte_eth_dev *dev)
 {
 	char *name = dev->data->name;
-	struct bond_dev_private *internals = dev->data->dev_private;
+	struct bond_dev_private *internals = rte_eth_private_by_dev(dev);
 	struct rte_kvargs *kvlist = internals->kvlist;
 	int arg_count;
 	uint8_t port_id = dev - rte_eth_devices;