summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorViacheslav Ovsiienko <viacheslavo@mellanox.com>2019-09-25 07:53:31 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-10-08 12:11:26 +0200
commit09a16bcab7b61acf186c596b5be6c13f3b4c9e65 (patch)
treefcb3607de951cf4b78416d26a2c1a784888691ac /drivers/net/mlx5/mlx5_ethdev.c
parentd5c06b1b10ae06f99082324b6988ca2ecef3a374 (diff)
downloaddpdk-next-eventdev-09a16bcab7b61acf186c596b5be6c13f3b4c9e65.zip
dpdk-next-eventdev-09a16bcab7b61acf186c596b5be6c13f3b4c9e65.tar.gz
dpdk-next-eventdev-09a16bcab7b61acf186c596b5be6c13f3b4c9e65.tar.xz
net/mlx5: elaborate E-Switch port parameters query
The routine mlx5_port_to_eswitch_info() is elaborated to two ones (get E-Switch port parameters by port and by device pointer) and simplified to returning structure containing all parameters instead of copying. Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com> Acked-by: Matan Azrad <matan@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 71f63ac..27372f1 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1660,7 +1660,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,
}
/**
- * Get the E-Switch domain id this port belongs to.
+ * Get the E-Switch parameters by port id.
*
* @param[in] port
* Device port id.
@@ -1670,34 +1670,57 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list,
* The port id of the port in the E-Switch.
*
* @return
- * 0 on success, a negative errno value otherwise and rte_errno is set.
+ * pointer to device private data structure containing data needed
+ * on success, NULL otherwise and rte_errno is set.
*/
-int
-mlx5_port_to_eswitch_info(uint16_t port,
- uint16_t *es_domain_id, uint16_t *es_port_id)
+struct mlx5_priv *
+mlx5_port_to_eswitch_info(uint16_t port)
{
struct rte_eth_dev *dev;
struct mlx5_priv *priv;
if (port >= RTE_MAX_ETHPORTS) {
rte_errno = EINVAL;
- return -rte_errno;
+ return NULL;
}
if (!rte_eth_dev_is_valid_port(port)) {
rte_errno = ENODEV;
- return -rte_errno;
+ return NULL;
}
dev = &rte_eth_devices[port];
priv = dev->data->dev_private;
if (!(priv->representor || priv->master)) {
rte_errno = EINVAL;
- return -rte_errno;
+ return NULL;
}
- if (es_domain_id)
- *es_domain_id = priv->domain_id;
- if (es_port_id)
- *es_port_id = priv->vport_id;
- return 0;
+ return priv;
+}
+
+/**
+ * Get the E-Switch parameters by device instance.
+ *
+ * @param[in] port
+ * Device port id.
+ * @param[out] es_domain_id
+ * E-Switch domain id.
+ * @param[out] es_port_id
+ * The port id of the port in the E-Switch.
+ *
+ * @return
+ * pointer to device private data structure containing data needed
+ * on success, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_priv *
+mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev)
+{
+ struct mlx5_priv *priv;
+
+ priv = dev->data->dev_private;
+ if (!(priv->representor || priv->master)) {
+ rte_errno = EINVAL;
+ return NULL;
+ }
+ return priv;
}
/**