diff mbox series

[2/2] net/cnxk: integrate bpfcount get MBOX interface

Message ID 20211102055802.1801583-2-rkudurumalla@marvell.com (mailing list archive)
State Superseded, archived
Headers show
Series [1/2] common/cnxk: change policer timeuint to configured value | expand

Checks

Context Check Description
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/checkpatch success coding style OK

Commit Message

Rakesh Kudurumalla Nov. 2, 2021, 5:58 a.m. UTC
Bpf count is updated in meter capabilities during device
initialization using mbox interface

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
 drivers/net/cnxk/cn10k_rte_flow.c  |  2 +-
 drivers/net/cnxk/cnxk_ethdev.c     |  4 ++-
 drivers/net/cnxk/cnxk_ethdev.h     |  1 +
 drivers/net/cnxk/cnxk_ethdev_mtr.c | 39 ++++++++++++++++++++++++------
 4 files changed, 37 insertions(+), 9 deletions(-)

Comments

Jerin Jacob Nov. 3, 2021, 3:19 p.m. UTC | #1
On Tue, Nov 2, 2021 at 11:29 AM Rakesh Kudurumalla
<rkudurumalla@marvell.com> wrote:
>
> Bpf count is updated in meter capabilities during device
> initialization using mbox interface
>
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>

Updated the commit to:


    net/cnxk: integrate BPF count get mailbox

    Bandwidth profile count is updated in meter capabilities during device
    initialization using mbox interface.

    Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
    Acked-by: Jerin Jacob <jerinj@marvell.com>


Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks

> ---
>  drivers/net/cnxk/cn10k_rte_flow.c  |  2 +-
>  drivers/net/cnxk/cnxk_ethdev.c     |  4 ++-
>  drivers/net/cnxk/cnxk_ethdev.h     |  1 +
>  drivers/net/cnxk/cnxk_ethdev_mtr.c | 39 ++++++++++++++++++++++++------
>  4 files changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/cnxk/cn10k_rte_flow.c b/drivers/net/cnxk/cn10k_rte_flow.c
> index dff4c7746c..b830abe63e 100644
> --- a/drivers/net/cnxk/cn10k_rte_flow.c
> +++ b/drivers/net/cnxk/cn10k_rte_flow.c
> @@ -249,7 +249,7 @@ cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
>
>         mtr_id = flow->mtr_id;
>         rc = cnxk_flow_destroy(eth_dev, flow, error);
> -       if (!rc) {
> +       if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) {
>                 rc = cn10k_mtr_destroy(eth_dev, mtr_id);
>                 if (rc) {
>                         rte_flow_error_set(error, ENXIO,
> diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
> index db54468dbc..a7d9978d70 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.c
> +++ b/drivers/net/cnxk/cnxk_ethdev.c
> @@ -730,11 +730,13 @@ nix_free_queue_mem(struct cnxk_eth_dev *dev)
>  static int
>  nix_ingress_policer_setup(struct cnxk_eth_dev *dev)
>  {
> +       struct rte_eth_dev *eth_dev = dev->eth_dev;
> +
>         TAILQ_INIT(&dev->mtr_profiles);
>         TAILQ_INIT(&dev->mtr_policy);
>         TAILQ_INIT(&dev->mtr);
>
> -       return 0;
> +       return nix_mtr_capabilities_init(eth_dev);
>  }
>
>  static int
> diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
> index 7e4939f0b9..d7c4b3e319 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.h
> +++ b/drivers/net/cnxk/cnxk_ethdev.h
> @@ -590,6 +590,7 @@ struct cnxk_meter_node *nix_get_mtr(struct rte_eth_dev *eth_dev,
>                                     uint32_t cur_id);
>  int nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id,
>                          uint32_t level);
> +int nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev);
>  int nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id);
>  int nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id);
>  int nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
> diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> index 22c85336d9..39d8563826 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
> @@ -28,7 +28,6 @@ static const enum roc_nix_bpf_level_flag lvl_map[] = {ROC_NIX_BPF_LEVEL_F_LEAF,
>                                                       ROC_NIX_BPF_LEVEL_F_TOP};
>
>  static struct rte_mtr_capabilities mtr_capa = {
> -       .n_max = NIX_MTR_COUNT_MAX,
>         .n_shared_max = NIX_MTR_COUNT_PER_FLOW,
>         /* .identical = , */
>         .shared_identical = true,
> @@ -36,11 +35,7 @@ static struct rte_mtr_capabilities mtr_capa = {
>         .chaining_n_mtrs_per_flow_max = NIX_MTR_COUNT_PER_FLOW,
>         .chaining_use_prev_mtr_color_supported = true,
>         .chaining_use_prev_mtr_color_enforced = true,
> -       .meter_srtcm_rfc2697_n_max = NIX_MTR_COUNT_MAX,
> -       .meter_trtcm_rfc2698_n_max = NIX_MTR_COUNT_MAX,
> -       .meter_trtcm_rfc4115_n_max = NIX_MTR_COUNT_MAX,
>         .meter_rate_max = NIX_BPF_RATE_MAX / 8, /* Bytes per second */
> -       .meter_policy_n_max = NIX_MTR_COUNT_MAX,
>         .color_aware_srtcm_rfc2697_supported = true,
>         .color_aware_trtcm_rfc2698_supported = true,
>         .color_aware_trtcm_rfc4115_supported = true,
> @@ -185,12 +180,33 @@ cnxk_nix_mtr_capabilities_get(struct rte_eth_dev *dev,
>                               struct rte_mtr_capabilities *capa,
>                               struct rte_mtr_error *error)
>  {
> +       struct cnxk_eth_dev *eth_dev = cnxk_eth_pmd_priv(dev);
> +       uint16_t count[ROC_NIX_BPF_LEVEL_MAX] = {0};
> +       uint8_t lvl_mask = ROC_NIX_BPF_LEVEL_F_LEAF | ROC_NIX_BPF_LEVEL_F_MID |
> +                          ROC_NIX_BPF_LEVEL_F_TOP;
> +       struct roc_nix *nix = &eth_dev->nix;
> +       int rc;
> +       int i;
> +
>         RTE_SET_USED(dev);
>
>         if (!capa)
>                 return -rte_mtr_error_set(error, EINVAL,
> -                                         RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> -                                         "NULL input parameter");
> +                               RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
> +                               "NULL input parameter");
> +
> +       rc = roc_nix_bpf_count_get(nix, lvl_mask, count);
> +       if (rc)
> +               return rc;
> +
> +       for (i = 0; i < ROC_NIX_BPF_LEVEL_MAX; i++)
> +               mtr_capa.n_max += count[i];
> +
> +       mtr_capa.meter_srtcm_rfc2697_n_max = mtr_capa.n_max;
> +       mtr_capa.meter_trtcm_rfc2698_n_max = mtr_capa.n_max;
> +       mtr_capa.meter_trtcm_rfc4115_n_max = mtr_capa.n_max;
> +       mtr_capa.meter_policy_n_max = mtr_capa.n_max;
> +
>         *capa = mtr_capa;
>         return 0;
>  }
> @@ -1339,3 +1355,12 @@ nix_mtr_color_action_validate(struct rte_eth_dev *eth_dev, uint32_t id,
>
>         return 0;
>  }
> +
> +int
> +nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev)
> +{
> +       struct rte_mtr_capabilities capa;
> +       struct rte_mtr_error error;
> +
> +       return cnxk_nix_mtr_capabilities_get(eth_dev, &capa, &error);
> +}
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/net/cnxk/cn10k_rte_flow.c b/drivers/net/cnxk/cn10k_rte_flow.c
index dff4c7746c..b830abe63e 100644
--- a/drivers/net/cnxk/cn10k_rte_flow.c
+++ b/drivers/net/cnxk/cn10k_rte_flow.c
@@ -249,7 +249,7 @@  cn10k_flow_destroy(struct rte_eth_dev *eth_dev, struct rte_flow *rte_flow,
 
 	mtr_id = flow->mtr_id;
 	rc = cnxk_flow_destroy(eth_dev, flow, error);
-	if (!rc) {
+	if (!rc && mtr_id != ROC_NIX_MTR_ID_INVALID) {
 		rc = cn10k_mtr_destroy(eth_dev, mtr_id);
 		if (rc) {
 			rte_flow_error_set(error, ENXIO,
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index db54468dbc..a7d9978d70 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -730,11 +730,13 @@  nix_free_queue_mem(struct cnxk_eth_dev *dev)
 static int
 nix_ingress_policer_setup(struct cnxk_eth_dev *dev)
 {
+	struct rte_eth_dev *eth_dev = dev->eth_dev;
+
 	TAILQ_INIT(&dev->mtr_profiles);
 	TAILQ_INIT(&dev->mtr_policy);
 	TAILQ_INIT(&dev->mtr);
 
-	return 0;
+	return nix_mtr_capabilities_init(eth_dev);
 }
 
 static int
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index 7e4939f0b9..d7c4b3e319 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -590,6 +590,7 @@  struct cnxk_meter_node *nix_get_mtr(struct rte_eth_dev *eth_dev,
 				    uint32_t cur_id);
 int nix_mtr_level_update(struct rte_eth_dev *eth_dev, uint32_t id,
 			 uint32_t level);
+int nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev);
 int nix_mtr_configure(struct rte_eth_dev *eth_dev, uint32_t id);
 int nix_mtr_connect(struct rte_eth_dev *eth_dev, uint32_t id);
 int nix_mtr_destroy(struct rte_eth_dev *eth_dev, uint32_t id,
diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c
index 22c85336d9..39d8563826 100644
--- a/drivers/net/cnxk/cnxk_ethdev_mtr.c
+++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c
@@ -28,7 +28,6 @@  static const enum roc_nix_bpf_level_flag lvl_map[] = {ROC_NIX_BPF_LEVEL_F_LEAF,
 						      ROC_NIX_BPF_LEVEL_F_TOP};
 
 static struct rte_mtr_capabilities mtr_capa = {
-	.n_max = NIX_MTR_COUNT_MAX,
 	.n_shared_max = NIX_MTR_COUNT_PER_FLOW,
 	/* .identical = , */
 	.shared_identical = true,
@@ -36,11 +35,7 @@  static struct rte_mtr_capabilities mtr_capa = {
 	.chaining_n_mtrs_per_flow_max = NIX_MTR_COUNT_PER_FLOW,
 	.chaining_use_prev_mtr_color_supported = true,
 	.chaining_use_prev_mtr_color_enforced = true,
-	.meter_srtcm_rfc2697_n_max = NIX_MTR_COUNT_MAX,
-	.meter_trtcm_rfc2698_n_max = NIX_MTR_COUNT_MAX,
-	.meter_trtcm_rfc4115_n_max = NIX_MTR_COUNT_MAX,
 	.meter_rate_max = NIX_BPF_RATE_MAX / 8, /* Bytes per second */
-	.meter_policy_n_max = NIX_MTR_COUNT_MAX,
 	.color_aware_srtcm_rfc2697_supported = true,
 	.color_aware_trtcm_rfc2698_supported = true,
 	.color_aware_trtcm_rfc4115_supported = true,
@@ -185,12 +180,33 @@  cnxk_nix_mtr_capabilities_get(struct rte_eth_dev *dev,
 			      struct rte_mtr_capabilities *capa,
 			      struct rte_mtr_error *error)
 {
+	struct cnxk_eth_dev *eth_dev = cnxk_eth_pmd_priv(dev);
+	uint16_t count[ROC_NIX_BPF_LEVEL_MAX] = {0};
+	uint8_t lvl_mask = ROC_NIX_BPF_LEVEL_F_LEAF | ROC_NIX_BPF_LEVEL_F_MID |
+			   ROC_NIX_BPF_LEVEL_F_TOP;
+	struct roc_nix *nix = &eth_dev->nix;
+	int rc;
+	int i;
+
 	RTE_SET_USED(dev);
 
 	if (!capa)
 		return -rte_mtr_error_set(error, EINVAL,
-					  RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
-					  "NULL input parameter");
+				RTE_MTR_ERROR_TYPE_MTR_PARAMS, NULL,
+				"NULL input parameter");
+
+	rc = roc_nix_bpf_count_get(nix, lvl_mask, count);
+	if (rc)
+		return rc;
+
+	for (i = 0; i < ROC_NIX_BPF_LEVEL_MAX; i++)
+		mtr_capa.n_max += count[i];
+
+	mtr_capa.meter_srtcm_rfc2697_n_max = mtr_capa.n_max;
+	mtr_capa.meter_trtcm_rfc2698_n_max = mtr_capa.n_max;
+	mtr_capa.meter_trtcm_rfc4115_n_max = mtr_capa.n_max;
+	mtr_capa.meter_policy_n_max = mtr_capa.n_max;
+
 	*capa = mtr_capa;
 	return 0;
 }
@@ -1339,3 +1355,12 @@  nix_mtr_color_action_validate(struct rte_eth_dev *eth_dev, uint32_t id,
 
 	return 0;
 }
+
+int
+nix_mtr_capabilities_init(struct rte_eth_dev *eth_dev)
+{
+	struct rte_mtr_capabilities capa;
+	struct rte_mtr_error error;
+
+	return cnxk_nix_mtr_capabilities_get(eth_dev, &capa, &error);
+}