[v8,4/4] net/cnxk: add telemetry endpoing to ethdev
Checks
Commit Message
Add telemetry endpoint to ethdev.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
drivers/net/cnxk/meson.build | 1 +
2 files changed, 130 insertions(+)
create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
Comments
On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Add telemetry endpoint to ethdev.
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
> drivers/net/cnxk/meson.build | 1 +
> 2 files changed, 130 insertions(+)
> create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> new file mode 100644
> index 0000000000..de8c468670
> --- /dev/null
> +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> @@ -0,0 +1,129 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2021 Marvell International Ltd.
> + */
> +
> +#include <rte_telemetry.h>
> +
> +#include "cnxk_ethdev.h"
> +
> +/* Macro to count no of words in eth_info_s size */
> +#define ETH_INFO_SZ \
> + (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \
> + sizeof(uint64_t))
> +#define MACADDR_LEN 18
> +
> +static int
> +ethdev_tel_handle_info(const char *cmd __rte_unused,
> + const char *params __rte_unused, struct rte_tel_data *d)
> +{
> + struct rte_eth_dev *eth_dev;
> + struct rte_tel_data *i_data;
> + struct cnxk_eth_dev *dev;
> + union eth_info_u {
> + struct eth_info_s {
> + /** PF/VF information */
> + uint16_t pf_func;
> + /** No of rx queues */
> + uint16_t rx_queues;
> + /** No of tx queues */
> + uint16_t tx_queues;
> + /** Port ID */
> + uint16_t port_id;
> + /** MAC entries */
> + char mac_addr[MACADDR_LEN];
> + uint8_t max_mac_entries;
> + bool dmac_filter_ena;
> + uint8_t dmac_filter_count;
> + uint16_t flags;
> + uint8_t ptype_disable;
> + bool scalar_ena;
> + bool ptp_ena;
> + /* Offload capabilities */
> + uint64_t rx_offload_capa;
> + uint64_t tx_offload_capa;
> + uint32_t speed_capa;
> + /* Configured offloads */
> + uint64_t rx_offloads;
> + uint64_t tx_offloads;
> + /* Platform specific offload flags */
> + uint16_t rx_offload_flags;
> + uint16_t tx_offload_flags;
> + /* ETHDEV RSS HF bitmask */
> + uint64_t ethdev_rss_hf;
+ Ethdev, , mempool and telemetry maintainers
All of the above data except[1] is generic data that can be derived
from ethdev APIs or ethdev data from lib/ethdev itself,
IMO, We should avoid duplicating this in driver and make useful for
other driver/application by adding generic endpoint in ethdev.
Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
mempool subsystem.
Thoughts from Maintainers?
[1]
uint8_t ptype_disable;
bool scalar_ena;
bool ptp_ena;
uint16_t flags;
On Tue, Sep 21, 2021 at 04:57:52PM +0530, Jerin Jacob wrote:
> On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com> wrote:
> >
> > Add telemetry endpoint to ethdev.
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> > drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
> > drivers/net/cnxk/meson.build | 1 +
> > 2 files changed, 130 insertions(+)
> > create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
> >
> > diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > new file mode 100644
> > index 0000000000..de8c468670
> > --- /dev/null
> > +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > @@ -0,0 +1,129 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(C) 2021 Marvell International Ltd.
> > + */
> > +
> > +#include <rte_telemetry.h>
> > +
> > +#include "cnxk_ethdev.h"
> > +
> > +/* Macro to count no of words in eth_info_s size */
> > +#define ETH_INFO_SZ \
> > + (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \
> > + sizeof(uint64_t))
> > +#define MACADDR_LEN 18
> > +
> > +static int
> > +ethdev_tel_handle_info(const char *cmd __rte_unused,
> > + const char *params __rte_unused, struct rte_tel_data *d)
> > +{
> > + struct rte_eth_dev *eth_dev;
> > + struct rte_tel_data *i_data;
> > + struct cnxk_eth_dev *dev;
> > + union eth_info_u {
> > + struct eth_info_s {
> > + /** PF/VF information */
> > + uint16_t pf_func;
> > + /** No of rx queues */
> > + uint16_t rx_queues;
> > + /** No of tx queues */
> > + uint16_t tx_queues;
> > + /** Port ID */
> > + uint16_t port_id;
> > + /** MAC entries */
> > + char mac_addr[MACADDR_LEN];
> > + uint8_t max_mac_entries;
> > + bool dmac_filter_ena;
> > + uint8_t dmac_filter_count;
> > + uint16_t flags;
> > + uint8_t ptype_disable;
> > + bool scalar_ena;
> > + bool ptp_ena;
> > + /* Offload capabilities */
> > + uint64_t rx_offload_capa;
> > + uint64_t tx_offload_capa;
> > + uint32_t speed_capa;
> > + /* Configured offloads */
> > + uint64_t rx_offloads;
> > + uint64_t tx_offloads;
> > + /* Platform specific offload flags */
> > + uint16_t rx_offload_flags;
> > + uint16_t tx_offload_flags;
> > + /* ETHDEV RSS HF bitmask */
> > + uint64_t ethdev_rss_hf;
>
> + Ethdev, , mempool and telemetry maintainers
>
> All of the above data except[1] is generic data that can be derived
> from ethdev APIs or ethdev data from lib/ethdev itself,
> IMO, We should avoid duplicating this in driver and make useful for
> other driver/application by adding generic endpoint in ethdev.
> Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
> mempool subsystem.
>
> Thoughts from Maintainers?
>
Not a maintainer of those libs, but +1 to making anything generic that can
be, save reimplementing things multiple times in drivers.
On Tue, Sep 21, 2021 at 12:53:53PM +0100, Bruce Richardson wrote:
> On Tue, Sep 21, 2021 at 04:57:52PM +0530, Jerin Jacob wrote:
> > On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
> > <gmuthukrishn@marvell.com> wrote:
> > >
> > > Add telemetry endpoint to ethdev.
> > >
> > > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > > ---
> > > drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
> > > drivers/net/cnxk/meson.build | 1 +
> > > 2 files changed, 130 insertions(+)
> > > create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > >
> > > diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > > new file mode 100644
> > > index 0000000000..de8c468670
> > > --- /dev/null
> > > +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > > @@ -0,0 +1,129 @@
> > > +/* SPDX-License-Identifier: BSD-3-Clause
> > > + * Copyright(C) 2021 Marvell International Ltd.
> > > + */
> > > +
> > > +#include <rte_telemetry.h>
> > > +
> > > +#include "cnxk_ethdev.h"
> > > +
> > > +/* Macro to count no of words in eth_info_s size */
> > > +#define ETH_INFO_SZ \
> > > + (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \
> > > + sizeof(uint64_t))
> > > +#define MACADDR_LEN 18
> > > +
> > > +static int
> > > +ethdev_tel_handle_info(const char *cmd __rte_unused,
> > > + const char *params __rte_unused, struct rte_tel_data *d)
> > > +{
> > > + struct rte_eth_dev *eth_dev;
> > > + struct rte_tel_data *i_data;
> > > + struct cnxk_eth_dev *dev;
> > > + union eth_info_u {
> > > + struct eth_info_s {
> > > + /** PF/VF information */
> > > + uint16_t pf_func;
> > > + /** No of rx queues */
> > > + uint16_t rx_queues;
> > > + /** No of tx queues */
> > > + uint16_t tx_queues;
> > > + /** Port ID */
> > > + uint16_t port_id;
> > > + /** MAC entries */
> > > + char mac_addr[MACADDR_LEN];
> > > + uint8_t max_mac_entries;
> > > + bool dmac_filter_ena;
> > > + uint8_t dmac_filter_count;
> > > + uint16_t flags;
> > > + uint8_t ptype_disable;
> > > + bool scalar_ena;
> > > + bool ptp_ena;
> > > + /* Offload capabilities */
> > > + uint64_t rx_offload_capa;
> > > + uint64_t tx_offload_capa;
> > > + uint32_t speed_capa;
> > > + /* Configured offloads */
> > > + uint64_t rx_offloads;
> > > + uint64_t tx_offloads;
> > > + /* Platform specific offload flags */
> > > + uint16_t rx_offload_flags;
> > > + uint16_t tx_offload_flags;
> > > + /* ETHDEV RSS HF bitmask */
> > > + uint64_t ethdev_rss_hf;
> >
> > + Ethdev, , mempool and telemetry maintainers
> >
> > All of the above data except[1] is generic data that can be derived
> > from ethdev APIs or ethdev data from lib/ethdev itself,
> > IMO, We should avoid duplicating this in driver and make useful for
> > other driver/application by adding generic endpoint in ethdev.
> > Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
> > mempool subsystem.
> >
> > Thoughts from Maintainers?
> >
> Not a maintainer of those libs, but +1 to making anything generic that can
> be, save reimplementing things multiple times in drivers.
I agree, I feel it would make more sense to have most of the job done in the
mempool library in generic. A new ops could be added to fill driver-specific
info.
new file mode 100644
@@ -0,0 +1,129 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ \
+ (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \
+ sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+ const char *params __rte_unused, struct rte_tel_data *d)
+{
+ struct rte_eth_dev *eth_dev;
+ struct rte_tel_data *i_data;
+ struct cnxk_eth_dev *dev;
+ union eth_info_u {
+ struct eth_info_s {
+ /** PF/VF information */
+ uint16_t pf_func;
+ /** No of rx queues */
+ uint16_t rx_queues;
+ /** No of tx queues */
+ uint16_t tx_queues;
+ /** Port ID */
+ uint16_t port_id;
+ /** MAC entries */
+ char mac_addr[MACADDR_LEN];
+ uint8_t max_mac_entries;
+ bool dmac_filter_ena;
+ uint8_t dmac_filter_count;
+ uint16_t flags;
+ uint8_t ptype_disable;
+ bool scalar_ena;
+ bool ptp_ena;
+ /* Offload capabilities */
+ uint64_t rx_offload_capa;
+ uint64_t tx_offload_capa;
+ uint32_t speed_capa;
+ /* Configured offloads */
+ uint64_t rx_offloads;
+ uint64_t tx_offloads;
+ /* Platform specific offload flags */
+ uint16_t rx_offload_flags;
+ uint16_t tx_offload_flags;
+ /* ETHDEV RSS HF bitmask */
+ uint64_t ethdev_rss_hf;
+ } info;
+ uint64_t val[ETH_INFO_SZ];
+ } eth_info;
+ struct eth_info_s *info;
+ unsigned int i, j = 0;
+ int n_ports;
+
+ n_ports = rte_eth_dev_count_avail();
+ if (!n_ports) {
+ plt_err("No active ethernet ports found.");
+ return -1;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+ i_data = rte_tel_data_alloc();
+ rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+
+ for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+ /* Skip if port is unused */
+ if (!rte_eth_dev_is_valid_port(i))
+ continue;
+
+ eth_dev = &rte_eth_devices[i];
+ if (eth_dev) {
+ memset(ð_info, 0, sizeof(eth_info));
+ info = ð_info.info;
+ dev = cnxk_eth_pmd_priv(eth_dev);
+ if (dev) {
+ info->pf_func = roc_nix_get_pf_func(&dev->nix);
+ memset(info->mac_addr, 0, MACADDR_LEN);
+ snprintf(info->mac_addr, MACADDR_LEN,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ dev->mac_addr[0], dev->mac_addr[1],
+ dev->mac_addr[2], dev->mac_addr[3],
+ dev->mac_addr[4], dev->mac_addr[5]);
+ info->max_mac_entries = dev->max_mac_entries;
+ info->dmac_filter_ena = dev->dmac_filter_enable;
+ info->dmac_filter_count =
+ dev->dmac_filter_count;
+ info->flags = dev->flags;
+ info->ptype_disable = dev->ptype_disable;
+ info->scalar_ena = dev->scalar_ena;
+ info->ptp_ena = dev->ptp_en;
+ info->rx_offload_capa = dev->rx_offload_capa;
+ info->tx_offload_capa = dev->tx_offload_capa;
+ info->rx_offloads = dev->rx_offloads;
+ info->tx_offloads = dev->tx_offloads;
+ info->rx_offload_flags = dev->rx_offload_flags;
+ info->tx_offload_flags = dev->tx_offload_flags;
+ info->ethdev_rss_hf = dev->ethdev_rss_hf;
+ }
+
+ if (eth_dev->data) {
+ info->rx_queues = eth_dev->data->nb_rx_queues;
+ info->tx_queues = eth_dev->data->nb_tx_queues;
+ info->port_id = eth_dev->data->port_id;
+ }
+
+ for (j = 0; j < ETH_INFO_SZ; j++)
+ rte_tel_data_add_array_u64(i_data,
+ eth_info.val[j]);
+
+ j++;
+ }
+ }
+
+ rte_tel_data_add_dict_container(d, "info", i_data, 0);
+ return 0;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+ rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+ "Returns ethdev device information");
+}
@@ -13,6 +13,7 @@ sources = files(
'cnxk_ethdev_devargs.c',
'cnxk_ethdev_ops.c',
'cnxk_ethdev_sec.c',
+ 'cnxk_ethdev_telemetry.c',
'cnxk_link.c',
'cnxk_lookup.c',
'cnxk_ptp.c',