From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D1E53A054F; Mon, 15 Mar 2021 15:00:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A1BB24269A; Mon, 15 Mar 2021 15:00:11 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 9850F24267F for ; Mon, 15 Mar 2021 15:00:07 +0100 (CET) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 6BF7D7F5AE; Mon, 15 Mar 2021 17:00:07 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 222687F5B8; Mon, 15 Mar 2021 16:59:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 222687F5B8 Authentication-Results: shelob.oktetlabs.ru/222687F5B8; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ferruh Yigit Cc: dev@dpdk.org, Vijay Kumar Srivastava Date: Mon, 15 Mar 2021 16:58:21 +0300 Message-Id: <20210315135823.605774-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210315135823.605774-1-andrew.rybchenko@oktetlabs.ru> References: <20210311110325.3291203-1-andrew.rybchenko@oktetlabs.ru> <20210315135823.605774-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 6/8] common/sfc_efx: add support to get the device class X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Vijay Kumar Srivastava Device class argument would be used to select compatible driver. Driver probe would be skipped for incompatible device class. Signed-off-by: Vijay Kumar Srivastava Signed-off-by: Andrew Rybchenko --- drivers/common/sfc_efx/sfc_efx.c | 49 ++++++++++++++++++++++++++++++ drivers/common/sfc_efx/sfc_efx.h | 34 +++++++++++++++++++++ drivers/common/sfc_efx/version.map | 2 ++ 3 files changed, 85 insertions(+) create mode 100644 drivers/common/sfc_efx/sfc_efx.h diff --git a/drivers/common/sfc_efx/sfc_efx.c b/drivers/common/sfc_efx/sfc_efx.c index d7a84c9835..a3146db255 100644 --- a/drivers/common/sfc_efx/sfc_efx.c +++ b/drivers/common/sfc_efx/sfc_efx.c @@ -7,12 +7,61 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include #include +#include +#include #include "sfc_efx_log.h" +#include "sfc_efx.h" uint32_t sfc_efx_logtype; +static int +sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key, + const char *class_str, void *opaque) +{ + enum sfc_efx_dev_class *dev_class = opaque; + + if (class_str == NULL) + return *dev_class; + + if (strcmp(class_str, "vdpa") == 0) { + *dev_class = SFC_EFX_DEV_CLASS_VDPA; + } else if (strcmp(class_str, "net") == 0) { + *dev_class = SFC_EFX_DEV_CLASS_NET; + } else { + SFC_EFX_LOG(ERR, "Unsupported class %s.", class_str); + *dev_class = SFC_EFX_DEV_CLASS_INVALID; + } + + return 0; +} + +enum sfc_efx_dev_class +sfc_efx_dev_class_get(struct rte_devargs *devargs) +{ + struct rte_kvargs *kvargs; + const char *key = SFC_EFX_KVARG_DEV_CLASS; + enum sfc_efx_dev_class dev_class = SFC_EFX_DEV_CLASS_NET; + + if (devargs == NULL) + return dev_class; + + kvargs = rte_kvargs_parse(devargs->args, NULL); + if (kvargs == NULL) + return dev_class; + + if (rte_kvargs_count(kvargs, key) != 0) { + rte_kvargs_process(kvargs, key, sfc_efx_kvarg_dev_class_handler, + &dev_class); + } + + rte_kvargs_free(kvargs); + + return dev_class; +} + RTE_INIT(sfc_efx_register_logtype) { int ret; diff --git a/drivers/common/sfc_efx/sfc_efx.h b/drivers/common/sfc_efx/sfc_efx.h new file mode 100644 index 0000000000..bbccd3e9e8 --- /dev/null +++ b/drivers/common/sfc_efx/sfc_efx.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019-2020 Xilinx, Inc. + * Copyright(c) 2019 Solarflare Communications Inc. + * + * This software was jointly developed between OKTET Labs (under contract + * for Solarflare) and Solarflare Communications, Inc. + */ + +#ifndef _SFC_EFX_H_ +#define _SFC_EFX_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SFC_EFX_KVARG_DEV_CLASS "class" + +enum sfc_efx_dev_class { + SFC_EFX_DEV_CLASS_INVALID = 0, + SFC_EFX_DEV_CLASS_NET, + SFC_EFX_DEV_CLASS_VDPA, + + SFC_EFX_DEV_NCLASS +}; + +__rte_internal +enum sfc_efx_dev_class sfc_efx_dev_class_get(struct rte_devargs *devargs); + +#ifdef __cplusplus +} +#endif + +#endif /* _SFC_EFX_H_ */ diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 403feeaf11..a3345d34f7 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -221,6 +221,8 @@ INTERNAL { efx_txq_nbufs; efx_txq_size; + sfc_efx_dev_class_get; + sfc_efx_mcdi_init; sfc_efx_mcdi_fini; -- 2.30.1