[02/15] common/octeontx2: add routine to check if rte_eth_dev belongs to otx2
diff mbox series

Message ID 1575806094-28391-3-git-send-email-anoobj@marvell.com
State Superseded
Delegated to: akhil goyal
Headers show
Series
  • add OCTEONTX2 inline IPsec support
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Anoob Joseph Dec. 8, 2019, 11:54 a.m. UTC
From: Vamsi Attunuru <vattunuru@marvell.com>

This routine returns true if given rte_eth_dev belongs to octeontx2

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
---
 drivers/common/octeontx2/otx2_common.c               | 20 ++++++++++++++++++++
 drivers/common/octeontx2/otx2_common.h               |  2 ++
 .../octeontx2/rte_common_octeontx2_version.map       |  1 +
 3 files changed, 23 insertions(+)

Comments

Jerin Jacob Dec. 9, 2019, 7:42 a.m. UTC | #1
On Sun, Dec 8, 2019 at 5:25 PM Anoob Joseph <anoobj@marvell.com> wrote:
>
> From: Vamsi Attunuru <vattunuru@marvell.com>
>
> This routine returns true if given rte_eth_dev belongs to octeontx2
>
> Signed-off-by: Anoob Joseph <anoobj@marvell.com>
> Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> ---
>  drivers/common/octeontx2/otx2_common.c               | 20 ++++++++++++++++++++
>  drivers/common/octeontx2/otx2_common.h               |  2 ++
>  .../octeontx2/rte_common_octeontx2_version.map       |  1 +
>  3 files changed, 23 insertions(+)
>
> diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
> index 7e45366..116db0f 100644
> --- a/drivers/common/octeontx2/otx2_common.c
> +++ b/drivers/common/octeontx2/otx2_common.c
> @@ -3,6 +3,7 @@
>   */
>
>  #include <rte_atomic.h>
> +#include <rte_ethdev.h>
>  #include <rte_malloc.h>
>  #include <rte_log.h>
>
> @@ -23,6 +24,25 @@ otx2_npa_set_defaults(struct otx2_idev_cfg *idev)
>
>  /**
>   * @internal
> + * Check if rte_eth_dev is otx2_eth_dev
> + */
> +uint8_t
> +otx2_is_ethdev(struct rte_eth_dev *eth_dev)
> +{
> +       struct rte_pci_device *pci_dev;
> +
> +       pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
> +
> +       if (pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_PF ||
> +           pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_VF ||
> +           pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_AF_VF)

Is PCI_DEVID_OCTEONTX2_RVU_SDP_VF and PCI_DEVID_OCTEONTX2_RVU_SDP_PF
also comes here? If yes. update the patch.


> +               return 1;
> +
> +       return 0;
> +}
> +
> +/**
> + * @internal
>   * Get intra device config structure.
>   */
>  struct otx2_idev_cfg *
> diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
> index f62c45d..d32e59a 100644
> --- a/drivers/common/octeontx2/otx2_common.h
> +++ b/drivers/common/octeontx2/otx2_common.h
> @@ -8,6 +8,7 @@
>  #include <rte_atomic.h>
>  #include <rte_common.h>
>  #include <rte_cycles.h>
> +#include <rte_ethdev.h>
>  #include <rte_memory.h>
>  #include <rte_memzone.h>
>  #include <rte_io.h>
> @@ -70,6 +71,7 @@ struct otx2_idev_cfg *otx2_intra_dev_get_cfg(void);
>  void otx2_sso_pf_func_set(uint16_t sso_pf_func);
>  uint16_t otx2_sso_pf_func_get(void);
>  uint16_t otx2_npa_pf_func_get(void);
> +uint8_t otx2_is_ethdev(struct rte_eth_dev *eth_dev);
>  struct otx2_npa_lf *otx2_npa_lf_obj_get(void);
>  void otx2_npa_set_defaults(struct otx2_idev_cfg *idev);
>  int otx2_npa_lf_active(void *dev);
> diff --git a/drivers/common/octeontx2/rte_common_octeontx2_version.map b/drivers/common/octeontx2/rte_common_octeontx2_version.map
> index adad21a..dac2283 100644
> --- a/drivers/common/octeontx2/rte_common_octeontx2_version.map
> +++ b/drivers/common/octeontx2/rte_common_octeontx2_version.map
> @@ -6,6 +6,7 @@ DPDK_20.0 {
>         otx2_dev_priv_init;
>         otx2_disable_irqs;
>         otx2_intra_dev_get_cfg;
> +       otx2_is_ethdev;
>         otx2_logtype_base;
>         otx2_logtype_dpi;
>         otx2_logtype_mbox;
> --
> 2.7.4
>

Patch
diff mbox series

diff --git a/drivers/common/octeontx2/otx2_common.c b/drivers/common/octeontx2/otx2_common.c
index 7e45366..116db0f 100644
--- a/drivers/common/octeontx2/otx2_common.c
+++ b/drivers/common/octeontx2/otx2_common.c
@@ -3,6 +3,7 @@ 
  */
 
 #include <rte_atomic.h>
+#include <rte_ethdev.h>
 #include <rte_malloc.h>
 #include <rte_log.h>
 
@@ -23,6 +24,25 @@  otx2_npa_set_defaults(struct otx2_idev_cfg *idev)
 
 /**
  * @internal
+ * Check if rte_eth_dev is otx2_eth_dev
+ */
+uint8_t
+otx2_is_ethdev(struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pci_dev;
+
+	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+
+	if (pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_PF ||
+	    pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_VF ||
+	    pci_dev->id.device_id == PCI_DEVID_OCTEONTX2_RVU_AF_VF)
+		return 1;
+
+	return 0;
+}
+
+/**
+ * @internal
  * Get intra device config structure.
  */
 struct otx2_idev_cfg *
diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
index f62c45d..d32e59a 100644
--- a/drivers/common/octeontx2/otx2_common.h
+++ b/drivers/common/octeontx2/otx2_common.h
@@ -8,6 +8,7 @@ 
 #include <rte_atomic.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
+#include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_io.h>
@@ -70,6 +71,7 @@  struct otx2_idev_cfg *otx2_intra_dev_get_cfg(void);
 void otx2_sso_pf_func_set(uint16_t sso_pf_func);
 uint16_t otx2_sso_pf_func_get(void);
 uint16_t otx2_npa_pf_func_get(void);
+uint8_t otx2_is_ethdev(struct rte_eth_dev *eth_dev);
 struct otx2_npa_lf *otx2_npa_lf_obj_get(void);
 void otx2_npa_set_defaults(struct otx2_idev_cfg *idev);
 int otx2_npa_lf_active(void *dev);
diff --git a/drivers/common/octeontx2/rte_common_octeontx2_version.map b/drivers/common/octeontx2/rte_common_octeontx2_version.map
index adad21a..dac2283 100644
--- a/drivers/common/octeontx2/rte_common_octeontx2_version.map
+++ b/drivers/common/octeontx2/rte_common_octeontx2_version.map
@@ -6,6 +6,7 @@  DPDK_20.0 {
 	otx2_dev_priv_init;
 	otx2_disable_irqs;
 	otx2_intra_dev_get_cfg;
+	otx2_is_ethdev;
 	otx2_logtype_base;
 	otx2_logtype_dpi;
 	otx2_logtype_mbox;