[08/19] net/cpfl: support vport list/info get

Message ID 20230809155134.539287-9-beilei.xing@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/cpfl: support port representor |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Xing, Beilei Aug. 9, 2023, 3:51 p.m. UTC
  From: Beilei Xing <beilei.xing@intel.com>

Support cp channel ops CPCHNL2_OP_CPF_GET_VPORT_LIST and
CPCHNL2_OP_CPF_GET_VPORT_INFO.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/cpfl/cpfl_ethdev.h |  8 ++++
 drivers/net/cpfl/cpfl_vchnl.c  | 72 ++++++++++++++++++++++++++++++++++
 drivers/net/cpfl/meson.build   |  1 +
 3 files changed, 81 insertions(+)
 create mode 100644 drivers/net/cpfl/cpfl_vchnl.c
  

Patch

diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 1f5c3a39b8..4b8c0da632 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -189,6 +189,14 @@  struct cpfl_adapter_ext {
 
 TAILQ_HEAD(cpfl_adapter_list, cpfl_adapter_ext);
 
+int cpfl_cc_vport_list_get(struct cpfl_adapter_ext *adapter,
+			   struct cpfl_vport_id *vi,
+			   struct cpchnl2_get_vport_list_response *response);
+int cpfl_cc_vport_info_get(struct cpfl_adapter_ext *adapter,
+			   struct cpchnl2_vport_id *vport_id,
+			   struct cpfl_vport_id *vi,
+			   struct cpchnl2_get_vport_info_response *response);
+
 #define CPFL_DEV_TO_PCI(eth_dev)		\
 	RTE_DEV_TO_PCI((eth_dev)->device)
 #define CPFL_ADAPTER_TO_EXT(p)					\
diff --git a/drivers/net/cpfl/cpfl_vchnl.c b/drivers/net/cpfl/cpfl_vchnl.c
new file mode 100644
index 0000000000..a21a4a451f
--- /dev/null
+++ b/drivers/net/cpfl/cpfl_vchnl.c
@@ -0,0 +1,72 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Intel Corporation
+ */
+
+#include "cpfl_ethdev.h"
+#include <idpf_common_virtchnl.h>
+
+int
+cpfl_cc_vport_list_get(struct cpfl_adapter_ext *adapter,
+		       struct cpfl_vport_id *vi,
+		       struct cpchnl2_get_vport_list_response *response)
+{
+	struct cpchnl2_get_vport_list_request request;
+	struct idpf_cmd_info args;
+	int err;
+
+	memset(&request, 0, sizeof(request));
+	request.func_type = vi->func_type;
+	request.pf_id = vi->pf_id;
+	request.vf_id = vi->vf_id;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = CPCHNL2_OP_GET_VPORT_LIST;
+	args.in_args = (uint8_t *)&request;
+	args.in_args_size = sizeof(struct cpchnl2_get_vport_list_request);
+	args.out_buffer = adapter->base.mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_vc_cmd_execute(&adapter->base, &args);
+	if (err != 0) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of CPCHNL2_OP_GET_VPORT_LIST");
+		return err;
+	}
+
+	rte_memcpy(response, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE);
+
+	return 0;
+}
+
+int
+cpfl_cc_vport_info_get(struct cpfl_adapter_ext *adapter,
+		       struct cpchnl2_vport_id *vport_id,
+		       struct cpfl_vport_id *vi,
+		       struct cpchnl2_get_vport_info_response *response)
+{
+	struct cpchnl2_get_vport_info_request request;
+	struct idpf_cmd_info args;
+	int err;
+
+	request.vport.vport_id = vport_id->vport_id;
+	request.vport.vport_type = vport_id->vport_type;
+	request.func.func_type = vi->func_type;
+	request.func.pf_id = vi->pf_id;
+	request.func.vf_id = vi->vf_id;
+
+	memset(&args, 0, sizeof(args));
+	args.ops = CPCHNL2_OP_GET_VPORT_INFO;
+	args.in_args = (uint8_t *)&request;
+	args.in_args_size = sizeof(struct cpchnl2_get_vport_info_request);
+	args.out_buffer = adapter->base.mbx_resp;
+	args.out_size = IDPF_DFLT_MBX_BUF_SIZE;
+
+	err = idpf_vc_cmd_execute(&adapter->base, &args);
+	if (err != 0) {
+		PMD_DRV_LOG(ERR, "Failed to execute command of CPCHNL2_OP_GET_VPORT_INFO");
+		return err;
+	}
+
+	rte_memcpy(response, args.out_buffer, sizeof(*response));
+
+	return 0;
+}
diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build
index 1d963e5fd1..fb075c6860 100644
--- a/drivers/net/cpfl/meson.build
+++ b/drivers/net/cpfl/meson.build
@@ -17,6 +17,7 @@  sources = files(
         'cpfl_ethdev.c',
         'cpfl_rxtx.c',
         'cpfl_representor.c',
+        'cpfl_vchnl.c',
 )
 
 if arch_subdir == 'x86'