[v6,2/4] common/sfc_efx/base: add API to get installed filters count

Message ID 20230622113104.261556-3-artemii.morozov@arknetworks.am (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: support VLAN stripping offload |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Artemii Morozov June 22, 2023, 11:31 a.m. UTC
  This API allows to get number of installed filters. This will
be used in the future patches.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 20 +++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
 drivers/common/sfc_efx/base/efx_filter.c  | 27 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  7 ++++++
 4 files changed, 60 insertions(+)
  

Comments

Andrew Rybchenko June 22, 2023, 11:51 a.m. UTC | #1
On 6/22/23 14:31, Artemii Morozov wrote:
> This API allows to get number of installed filters. This will
> be used in the future patches.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> ---
>   drivers/common/sfc_efx/base/ef10_filter.c | 20 +++++++++++++++++
>   drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
>   drivers/common/sfc_efx/base/efx_filter.c  | 27 +++++++++++++++++++++++
>   drivers/common/sfc_efx/base/efx_impl.h    |  7 ++++++
>   4 files changed, 60 insertions(+)
> 
> diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
> index d6940011c0..278502fb61 100644
> --- a/drivers/common/sfc_efx/base/ef10_filter.c
> +++ b/drivers/common/sfc_efx/base/ef10_filter.c
> @@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
>   	return (rc);
>   }
>   
> +	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count)
> +{
> +	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
> +	uint32_t filters_count;
> +
> +	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
> +	EFSYS_ASSERT(count != NULL);
> +
> +	filters_count = table->eft_unicst_filter_count +
> +			table->eft_mulcst_filter_count +
> +			table->eft_encap_filter_count;

I guess encap filters are orthogonal to Rx VLAN stripping. But may be it
is not a problem.

> +
> +	*count = filters_count;
> +
> +	return (0);
> +}
> +
>   		void
>   ef10_filter_get_default_rxq(
>   	__in		efx_nic_t *enp,
> diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
> index 877aedad45..914bba10ce 100644
> --- a/drivers/common/sfc_efx/base/ef10_impl.h
> +++ b/drivers/common/sfc_efx/base/ef10_impl.h
> @@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
>   	__in_ecount(6*count)		uint8_t const *addrs,
>   	__in				uint32_t count);
>   
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count);
> +
>   LIBEFX_INTERNAL
>   extern		void
>   ef10_filter_get_default_rxq(
> diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
> index 83c37ff859..a8b62ee88d 100644
> --- a/drivers/common/sfc_efx/base/efx_filter.c
> +++ b/drivers/common/sfc_efx/base/efx_filter.c
> @@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
>   	siena_filter_delete,		/* efo_delete */
>   	siena_filter_supported_filters,	/* efo_supported_filters */
>   	NULL,				/* efo_reconfigure */
> +	NULL,				/* efo_get_count */
>   };
>   #endif /* EFSYS_OPT_SIENA */
>   
> @@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
>   	ef10_filter_delete,		/* efo_delete */
>   	ef10_filter_supported_filters,	/* efo_supported_filters */
>   	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
>   };
>   #endif /* EFX_OPTS_EF10() */
>   
> @@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
>   	ef10_filter_delete,		/* efo_delete */
>   	ef10_filter_supported_filters,	/* efo_supported_filters */
>   	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
>   };
>   #endif /* EFSYS_OPT_RIVERHEAD */
>   
> @@ -306,6 +309,30 @@ efx_filter_reconfigure(
>   
>   	return (0);
>   
> +fail1:
> +	EFSYS_PROBE1(fail1, efx_rc_t, rc);
> +
> +	return (rc);
> +}
> +
> +	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count)
> +{
> +	efx_rc_t rc;
> +
> +	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
> +
> +	if (enp->en_efop->efo_get_count != NULL) {

It looks bad to return 0, but do not fill in count.
IMHO, it should be an error if callback is not provided.

> +		if ((rc = enp->en_efop->efo_get_count(enp, count)) != 0)
> +			goto fail1;
> +	}
> +
> +	return (0);
> +
>   fail1:
>   	EFSYS_PROBE1(fail1, efx_rc_t, rc);
>   
> diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
> index 45e99d01c5..d657734bc5 100644
> --- a/drivers/common/sfc_efx/base/efx_impl.h
> +++ b/drivers/common/sfc_efx/base/efx_impl.h
> @@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
>   	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
>   				   boolean_t, boolean_t, boolean_t,
>   				   uint8_t const *, uint32_t);
> +	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
>   } efx_filter_ops_t;
>   
>   LIBEFX_INTERNAL
> @@ -302,6 +303,12 @@ efx_filter_reconfigure(
>   	__in_ecount(6*count)		uint8_t const *addrs,
>   	__in				uint32_t count);
>   
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count);
> +
>   #endif /* EFSYS_OPT_FILTER */
>   
>   #if EFSYS_OPT_TUNNEL
  

Patch

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..278502fb61 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -2113,6 +2113,26 @@  ef10_filter_reconfigure(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
+	uint32_t filters_count;
+
+	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
+	EFSYS_ASSERT(count != NULL);
+
+	filters_count = table->eft_unicst_filter_count +
+			table->eft_mulcst_filter_count +
+			table->eft_encap_filter_count;
+
+	*count = filters_count;
+
+	return (0);
+}
+
 		void
 ef10_filter_get_default_rxq(
 	__in		efx_nic_t *enp,
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..914bba10ce 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1347,6 +1347,12 @@  ef10_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 LIBEFX_INTERNAL
 extern		void
 ef10_filter_get_default_rxq(
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..a8b62ee88d 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -53,6 +53,7 @@  static const efx_filter_ops_t	__efx_filter_siena_ops = {
 	siena_filter_delete,		/* efo_delete */
 	siena_filter_supported_filters,	/* efo_supported_filters */
 	NULL,				/* efo_reconfigure */
+	NULL,				/* efo_get_count */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -65,6 +66,7 @@  static const efx_filter_ops_t	__efx_filter_ef10_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFX_OPTS_EF10() */
 
@@ -77,6 +79,7 @@  static const efx_filter_ops_t	__efx_filter_rhead_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFSYS_OPT_RIVERHEAD */
 
@@ -306,6 +309,30 @@  efx_filter_reconfigure(
 
 	return (0);
 
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
+
+	if (enp->en_efop->efo_get_count != NULL) {
+		if ((rc = enp->en_efop->efo_get_count(enp, count)) != 0)
+			goto fail1;
+	}
+
+	return (0);
+
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..d657734bc5 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -288,6 +288,7 @@  typedef struct efx_filter_ops_s {
 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
 				   boolean_t, boolean_t, boolean_t,
 				   uint8_t const *, uint32_t);
+	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
 } efx_filter_ops_t;
 
 LIBEFX_INTERNAL
@@ -302,6 +303,12 @@  efx_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 #endif /* EFSYS_OPT_FILTER */
 
 #if EFSYS_OPT_TUNNEL