diff mbox series

[15/18] net/dpaa: add support for loopback API

Message ID 1513166759-13466-16-git-send-email-hemant.agrawal@nxp.com
State Superseded
Headers show
Series DPAA PMD improvements | expand

Commit Message

Hemant Agrawal Dec. 13, 2017, 12:05 p.m. UTC
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 drivers/net/dpaa/Makefile                 |  3 +++
 drivers/net/dpaa/dpaa_ethdev.c            | 42 +++++++++++++++++++++++++++++++
 drivers/net/dpaa/rte_pmd_dpaa.h           | 37 +++++++++++++++++++++++++++
 drivers/net/dpaa/rte_pmd_dpaa_version.map |  8 ++++++
 4 files changed, 90 insertions(+)
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa.h

-- 
2.7.4

Comments

Ferruh Yigit Jan. 9, 2018, 10:46 a.m. UTC | #1
On 12/13/2017 12:05 PM, Hemant Agrawal wrote:
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>


<...>

> @@ -0,0 +1,37 @@

> +/*-

> + *   Copyright 2017 NXP.

> + *

> + *   SPDX-License-Identifier:        BSD-3-Clause


I guess latest agreement was without break.

> + */

> +

> +#ifndef _PMD_DPAA_H_

> +#define _PMD_DPAA_H_

> +

> +/**

> + * @file rte_pmd_dpaa.h

> + *

> + * dpaa PMD specific functions.

> + *

> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice


What about adding a @warning for this note too, otherwise it is very easy to
miss note.

> + *

> + */

> +

> +#include <rte_ethdev.h>

> +

> +/**

> + * Enable/Disable TX loopback


I am for adding EXPERIMENTAL tag for API as well, otherwise it is easy to miss.
I suggest adding @warning as well to highlight is as done in rte_member.h

> + *

> + * @param port

> + *    The port identifier of the Ethernet device.

> + * @param on

> + *    1 - Enable TX loopback.

> + *    0 - Disable TX loopback.

> + * @return

> + *   - (0) if successful.

> + *   - (-ENODEV) if *port* invalid.

> + *   - (-EINVAL) if bad parameter.

> + */

> +int rte_pmd_dpaa_set_tx_loopback(uint8_t port,

> +				 uint8_t on);


PMD now has PMD specific API, this is public API, can you please update related
API documentations to document this API?

> +

> +#endif /* _PMD_DPAA_H_ */

> diff --git a/drivers/net/dpaa/rte_pmd_dpaa_version.map b/drivers/net/dpaa/rte_pmd_dpaa_version.map

> index a70bd19..d76acbd 100644

> --- a/drivers/net/dpaa/rte_pmd_dpaa_version.map

> +++ b/drivers/net/dpaa/rte_pmd_dpaa_version.map

> @@ -2,3 +2,11 @@ DPDK_17.11 {

>  

>  	local: *;

>  };

> +

> +DPDK_18.02 {


This API is EXPERIMENTAL (as far as I can see from above) so having an
experimental tag is better.

How to mark an API as experimental is not documented, we should indeed.

cc'ed Luca if I am missing steps related how to make an API experimental.

> +	global:

> +

> +	rte_pmd_dpaa_set_tx_loopback;

> +

> +	local: *;

> +} DPDK_17.11;

>
diff mbox series

Patch

diff --git a/drivers/net/dpaa/Makefile b/drivers/net/dpaa/Makefile
index 171686e..a99d1ee 100644
--- a/drivers/net/dpaa/Makefile
+++ b/drivers/net/dpaa/Makefile
@@ -60,4 +60,7 @@  LDLIBS += -lrte_mempool_dpaa
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_DPAA_PMD)-include := rte_pmd_dpaa.h
+
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 53b8c87..fcba929 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -64,6 +64,7 @@ 
 
 #include <dpaa_ethdev.h>
 #include <dpaa_rxtx.h>
+#include <rte_pmd_dpaa.h>
 
 #include <fsl_usd.h>
 #include <fsl_qman.h>
@@ -110,6 +111,8 @@  static const struct rte_dpaa_xstats_name_off dpaa_xstats_strings[] = {
 		offsetof(struct dpaa_if_stats, tund)},
 };
 
+static struct rte_dpaa_driver rte_dpaa_pmd;
+
 static int
 dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
@@ -733,6 +736,45 @@  static struct eth_dev_ops dpaa_devops = {
 	.fw_version_get		  = dpaa_fw_version_get,
 };
 
+static bool
+is_device_supported(struct rte_eth_dev *dev, struct rte_dpaa_driver *drv)
+{
+	if (strcmp(dev->device->driver->name,
+		   drv->driver.name))
+		return false;
+
+	return true;
+}
+
+static bool
+is_dpaa_supported(struct rte_eth_dev *dev)
+{
+	return is_device_supported(dev, &rte_dpaa_pmd);
+}
+
+int
+rte_pmd_dpaa_set_tx_loopback(uint8_t port, uint8_t on)
+{
+	struct rte_eth_dev *dev;
+	struct dpaa_if *dpaa_intf;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (!is_dpaa_supported(dev))
+		return -ENOTSUP;
+
+	dpaa_intf = dev->data->dev_private;
+
+	if (on)
+		fman_if_loopback_enable(dpaa_intf->fif);
+	else
+		fman_if_loopback_disable(dpaa_intf->fif);
+
+	return 0;
+}
+
 static int dpaa_fc_set_default(struct dpaa_if *dpaa_intf)
 {
 	struct rte_eth_fc_conf *fc_conf;
diff --git a/drivers/net/dpaa/rte_pmd_dpaa.h b/drivers/net/dpaa/rte_pmd_dpaa.h
new file mode 100644
index 0000000..4464dd4
--- /dev/null
+++ b/drivers/net/dpaa/rte_pmd_dpaa.h
@@ -0,0 +1,37 @@ 
+/*-
+ *   Copyright 2017 NXP.
+ *
+ *   SPDX-License-Identifier:        BSD-3-Clause
+ */
+
+#ifndef _PMD_DPAA_H_
+#define _PMD_DPAA_H_
+
+/**
+ * @file rte_pmd_dpaa.h
+ *
+ * dpaa PMD specific functions.
+ *
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ */
+
+#include <rte_ethdev.h>
+
+/**
+ * Enable/Disable TX loopback
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param on
+ *    1 - Enable TX loopback.
+ *    0 - Disable TX loopback.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_dpaa_set_tx_loopback(uint8_t port,
+				 uint8_t on);
+
+#endif /* _PMD_DPAA_H_ */
diff --git a/drivers/net/dpaa/rte_pmd_dpaa_version.map b/drivers/net/dpaa/rte_pmd_dpaa_version.map
index a70bd19..d76acbd 100644
--- a/drivers/net/dpaa/rte_pmd_dpaa_version.map
+++ b/drivers/net/dpaa/rte_pmd_dpaa_version.map
@@ -2,3 +2,11 @@  DPDK_17.11 {
 
 	local: *;
 };
+
+DPDK_18.02 {
+	global:
+
+	rte_pmd_dpaa_set_tx_loopback;
+
+	local: *;
+} DPDK_17.11;