DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ixgbe: clean up rte_eth_dev_info_get
@ 2017-01-25  2:39 Wenzhuo Lu
  2017-01-25  3:16 ` Tiwei Bie
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: Wenzhuo Lu @ 2017-01-25  2:39 UTC (permalink / raw)
  To: dev; +Cc: Wenzhuo Lu

It'not appropriate to call rte_eth_dev_info_get in PMD,
as rte_eth_dev_info_get need to get info from PMD.
Remove rte_eth_dev_info_get from PMD code and get the
info directly.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 144 ++++++++++++++++++---------------------
 1 file changed, 68 insertions(+), 76 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 64ce55a..f14a68b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4401,17 +4401,17 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 	int rar_entry;
 	uint8_t *new_mac = (uint8_t *)(mac_addr);
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -4902,17 +4902,17 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	struct ixgbe_hw *hw;
 	struct ixgbe_mac_info *mac;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -4932,17 +4932,17 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	struct ixgbe_hw *hw;
 	struct ixgbe_mac_info *mac;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -4961,17 +4961,17 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	struct ixgbe_hw *hw;
 	uint32_t ctrl;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (vlan_id > ETHER_MAX_VLAN_ID)
@@ -4997,14 +4997,12 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	struct ixgbe_hw *hw;
 	uint32_t ctrl;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
 	if (on > 1)
@@ -5031,14 +5029,12 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	int i;
 	int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
 	if (on > 1)
@@ -5061,18 +5057,18 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	struct ixgbe_hw *hw;
 	uint32_t reg_value;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
 	/* only support VF's 0 to 63 */
-	if ((vf >= dev_info.max_vfs) || (vf > 63))
+	if ((vf >= pci_dev->max_vfs) || (vf > 63))
 		return -EINVAL;
 
 	if (on > 1)
@@ -5094,19 +5090,21 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)
 {
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
+	struct ixgbe_hw *hw;
 	uint16_t queues_per_pool;
 	uint32_t q;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -5122,8 +5120,12 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	 * first 124 queues 0-123 will be allocated to VF's and only
 	 * the last 4 queues 123-127 will be assigned to the PF.
 	 */
-
-	queues_per_pool = dev_info.vmdq_queue_num / dev_info.max_vmdq_pools;
+	if (hw->mac.type == ixgbe_mac_82598EB)
+		queues_per_pool = (uint16_t)hw->mac.max_rx_queues /
+				  ETH_16_POOLS;
+	else
+		queues_per_pool = (uint16_t)hw->mac.max_rx_queues /
+				  ETH_64_POOLS;
 
 	for (q = 0; q < queues_per_pool; q++)
 		(*dev->dev_ops->vlan_strip_queue_set)(dev,
@@ -5136,19 +5138,19 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 {
 	int val = 0;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 	struct ixgbe_hw *hw;
 	uint32_t vmolr;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -5181,7 +5183,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 rte_pmd_ixgbe_set_vf_rx(uint8_t port, uint16_t vf, uint8_t on)
 {
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 	uint32_t reg, addr;
 	uint32_t val;
 	const uint8_t bit1 = 0x1;
@@ -5190,12 +5192,12 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -5231,7 +5233,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 rte_pmd_ixgbe_set_vf_tx(uint8_t port, uint16_t vf, uint8_t on)
 {
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
+	struct rte_pci_device *pci_dev;
 	uint32_t reg, addr;
 	uint32_t val;
 	const uint8_t bit1 = 0x1;
@@ -5241,12 +5243,12 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (on > 1)
@@ -5282,7 +5284,6 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 			uint64_t vf_mask, uint8_t vlan_on)
 {
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	int ret = 0;
 	uint16_t vf_idx;
 	struct ixgbe_hw *hw;
@@ -5290,9 +5291,8 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
 	if ((vlan > ETHER_MAX_VLAN_ID) || (vf_mask == 0))
@@ -5318,7 +5318,6 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
 	uint16_t tx_rate, uint64_t q_msk)
 {
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	struct ixgbe_hw *hw;
 	struct ixgbe_vf_info *vfinfo;
 	struct rte_eth_link link;
@@ -5332,13 +5331,13 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
 	dev = &rte_eth_devices[port];
-	rte_eth_dev_info_get(port, &dev_info);
+	pci_dev = IXGBE_DEV_TO_PCI(dev);
 	rte_eth_link_get_nowait(port, &link);
 
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	if (vf >= dev_info.max_vfs)
+	if (vf >= pci_dev->max_vfs)
 		return -EINVAL;
 
 	if (tx_rate > link.link_speed)
@@ -5347,7 +5346,6 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
 	if (q_msk == 0)
 		return 0;
 
-	pci_dev = IXGBE_DEV_TO_PCI(dev);
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
 	nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
@@ -8227,16 +8225,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	/* Stop the data paths */
@@ -8311,16 +8308,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	/* Stop the data paths */
@@ -8376,16 +8372,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
@@ -8402,16 +8397,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
@@ -8430,16 +8424,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl, i;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (idx != 0 && idx != 1)
@@ -8487,16 +8480,15 @@ int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
 {
 	struct ixgbe_hw *hw;
 	struct rte_eth_dev *dev;
-	struct rte_eth_dev_info dev_info;
 	uint32_t ctrl, i;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
-	rte_eth_dev_info_get(port, &dev_info);
-	if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+	dev = &rte_eth_devices[port];
+
+	if (is_ixgbe_pmd(dev->data->drv_name))
 		return -ENOTSUP;
 
-	dev = &rte_eth_devices[port];
 	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (idx != 0 && idx != 1)
-- 
1.9.3

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2017-02-08  0:54 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25  2:39 [dpdk-dev] [PATCH] net/ixgbe: clean up rte_eth_dev_info_get Wenzhuo Lu
2017-01-25  3:16 ` Tiwei Bie
2017-01-25  5:13   ` Lu, Wenzhuo
2017-01-25  5:24     ` Tiwei Bie
2017-01-30 12:15       ` Ferruh Yigit
2017-02-03  6:50         ` Lu, Wenzhuo
2017-02-03 11:52           ` Ferruh Yigit
2017-02-01 16:24 ` Ananyev, Konstantin
2017-02-01 17:40   ` Ferruh Yigit
2017-02-01 18:10     ` Ananyev, Konstantin
2017-02-01 18:18       ` Ferruh Yigit
2017-02-03  9:21       ` Iremonger, Bernard
2017-02-03  9:49         ` Ananyev, Konstantin
2017-02-03 10:02           ` Iremonger, Bernard
2017-02-03 12:00             ` Ferruh Yigit
2017-02-06  2:09 ` [dpdk-dev] [PATCH v2] " Wenzhuo Lu
2017-02-06  2:30   ` Tiwei Bie
2017-02-06  2:41     ` Lu, Wenzhuo
2017-02-06  2:51       ` Tiwei Bie
2017-02-06  2:59         ` Lu, Wenzhuo
2017-02-06  3:08           ` Tiwei Bie
2017-02-06  3:45             ` Lu, Wenzhuo
2017-02-06  4:57               ` Tiwei Bie
2017-02-06  5:17                 ` Lu, Wenzhuo
2017-02-06  5:26                   ` Tiwei Bie
2017-02-07  6:33 ` [dpdk-dev] [PATCH v3] " Wenzhuo Lu
2017-02-07 14:08   ` Ferruh Yigit
2017-02-07 14:09     ` Ferruh Yigit
2017-02-08  0:54       ` Lu, Wenzhuo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).