DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenjing Qiao <wenjing.qiao@intel.com>
To: jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com
Cc: dev@dpdk.org, Wenjing Qiao <wenjing.qiao@intel.com>,
	Jun Zhang <xuejun.zhang@intel.com>
Subject: [PATCH 14/18] common/idpf: add GNSS support over VF
Date: Thu, 13 Apr 2023 05:44:58 -0400	[thread overview]
Message-ID: <20230413094502.1714755-15-wenjing.qiao@intel.com> (raw)
In-Reply-To: <20230413094502.1714755-1-wenjing.qiao@intel.com>

This patch enables VF access to GNSS Console I2C.

Most of the opcodes in this implementation map directly to the
AQ commands for GNSS Console I2C Read and Write for GNSS status,
configuration, and NMEA messages.

Additionally there is VF and PF negotiation on GNSS Access
Capability through Extended PTP Capability Exchange. VF can
access GNSS Console I2C only if Extended PTP Capability
exchange indicates so.

Signed-off-by: Jun Zhang <xuejun.zhang@intel.com>
Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>
---
 drivers/common/idpf/base/virtchnl.h | 111 ++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/drivers/common/idpf/base/virtchnl.h b/drivers/common/idpf/base/virtchnl.h
index 54d66c4913..4e9cf9fdeb 100644
--- a/drivers/common/idpf/base/virtchnl.h
+++ b/drivers/common/idpf/base/virtchnl.h
@@ -197,6 +197,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_SYNCE_SET_CGU_DPLL_CONFIG = 126,
 	VIRTCHNL_OP_SYNCE_GET_CGU_INFO = 127,
 	VIRTCHNL_OP_SYNCE_GET_HW_INFO = 128,
+	VIRTCHNL_OP_GNSS_READ_I2C = 129,
+	VIRTCHNL_OP_GNSS_WRITE_I2C = 130,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -333,6 +335,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_SYNCE_GET_CGU_INFO";
 	case VIRTCHNL_OP_SYNCE_GET_HW_INFO:
 		return "VIRTCHNL_OP_SYNCE_GET_HW_INFO";
+	case VIRTCHNL_OP_GNSS_READ_I2C:
+		return "VIRTCHNL_OP_GNSS_READ_I2C";
+	case VIRTCHNL_OP_GNSS_WRITE_I2C:
+		return "VIRTCHNL_OP_GNSS_WRITE_I2C";
 	case VIRTCHNL_OP_ENABLE_QUEUES_V2:
 		return "VIRTCHNL_OP_ENABLE_QUEUES_V2";
 	case VIRTCHNL_OP_DISABLE_QUEUES_V2:
@@ -2117,6 +2123,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg);
  *   VIRTCHNL_OP_SYNCE_SET_CGU_DPLL_CONFIG
  *   VIRTCHNL_OP_SYNCE_GET_CGU_INFO
  *   VIRTCHNL_OP_SYNCE_GET_HW_INFO
+ *   VIRTCHNL_OP_GNSS_READ_I2C
+ *   VIRTCHNL_OP_GNSS_WRITE_I2C
  *
  * Support for offloading control of the device PTP hardware clock (PHC) is enabled
  * by VIRTCHNL_VF_CAP_PTP. This capability allows a VF to request that PF
@@ -2138,6 +2146,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg);
 #define VIRTCHNL_1588_PTP_CAP_PHC_REGS		BIT(4)
 #define VIRTCHNL_1588_PTP_CAP_PIN_CFG		BIT(5)
 #define VIRTCHNL_1588_PTP_CAP_SYNCE		BIT(6)
+#define VIRTCHNL_1588_PTP_CAP_GNSS		BIT(7)
 
 /**
  * virtchnl_phc_regs
@@ -2280,6 +2289,10 @@ enum virtchnl_ptp_tstamp_format {
  * VIRTCHNL_OP_SYNCE_GET_HW_INFO. It returns to VF all required HW details
  * needed for further processing.
  *
+ * VIRTCHNL_1588_PTP_CAP_GNSS indicates that the VF has access to GNSS related
+ * capabilities, i.e. Access onboard GNSS Module (if present) through I2C GNSS
+ * console for GNSS Configuration, Status, and NMEA Messages.
+ *
  * Note that in the future, additional capability flags may be added which
  * indicate additional extended support. All fields marked as reserved by this
  * header will be set to zero. VF implementations should verify this to ensure
@@ -3146,6 +3159,98 @@ struct virtchnl_synce_get_hw_info {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_synce_get_hw_info);
 
+/**
+ * virtchnl_link_topo_params
+ * @lport_num: link port number
+ * @lport_num_valid: link port number validity
+ * @node_type_ctx: node type & context
+ * @index: node index
+ *
+ * Structure used as part of virtchnl_link_topo_addr with gnss I2C read or write
+ * request. VF sets this structure field for GNSS I2C console Node, PF passes it
+ * on to AdminQ.
+ */
+struct virtchnl_link_topo_params {
+	u8 lport_num;
+	u8 lport_num_valid;
+	u8 node_type_ctx;
+#define VIRTCHNL_LINK_TOPO_NODE_TYPE_GPS	11
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_S		4
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_M		\
+				(0xF << VIRTCHNL_LINK_TOPO_NODE_CTX_S)
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_GLOBAL	0
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_BOARD	1
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_PORT	2
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_NODE	3
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_PROVIDED	4
+#define VIRTCHNL_LINK_TOPO_NODE_CTX_OVERRIDE	5
+	u8 index;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_link_topo_params);
+
+/**
+ * virtchnl_link_topo_addr
+ * @topo_params: link topo parameters
+ * @handle: link topo handle (board type, mezzaine / lom Type)
+ *
+ * Structure used as part of virtchnl_gnss_i2c read or write request. VF sets
+ * this structure field for GNSS I2C console Node, PF passes it on to AdminQ.
+ */
+struct virtchnl_link_topo_addr {
+	struct virtchnl_link_topo_params topo_params;
+	u16  handle;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_link_topo_addr);
+
+/**
+ * virtchnl_gnss_i2c
+ * @topo_addr: link topo address
+ * @i2c_addr: gnss console I2C Address
+ * @i2c_params: gnss console I2C Parameters
+ * @i2c_bus_addr: gnss console I2C Bus Address
+ * @i2c_data: Data to be written to gnss module
+ *
+ * Structure sent with VIRTCHNL_OP_GNSS_READ_I2C for GNSS Console I2C Read,
+ * or VIRTCHNL_OP_GNSS_WRITE_I2C for GNSS Console I2C Write. The request is
+ * acceptable only when VF negotiated VIRTCHNL_1588_PTP_CAP_GNSS capability
+ * with PF.
+ */
+struct virtchnl_gnss_i2c {
+	struct virtchnl_link_topo_addr topo_addr;
+	u16 i2c_addr;
+	u8 i2c_params;
+#define VIRTCHNL_I2C_DATA_SIZE_S	0
+#define VIRTCHNL_I2C_DATA_SIZE_M	(0xF << VIRTCHNL_I2C_DATA_SIZE_S)
+#define VIRTCHNL_I2C_ADDR_TYPE_M	BIT(4)
+#define VIRTCHNL_I2C_ADDR_TYPE_7BIT	0
+#define VIRTCHNL_I2C_ADDR_TYPE_10BIT	VIRTCHNL_I2C_ADDR_TYPE_M
+#define VIRTCHNL_I2C_DATA_OFFSET_S	5
+#define VIRTCHNL_I2C_DATA_OFFSET_M	(0x3 << VIRTCHNL_I2C_DATA_OFFSET_S)
+#define VIRTCHNL_I2C_USE_REPEATED_START	BIT(7)
+	u8 rsvd;
+	u16 i2c_bus_addr;
+#define VIRTCHNL_I2C_ADDR_7BIT_MASK	0x7F
+#define VIRTCHNL_I2C_ADDR_10BIT_MASK	0x3FF
+	u8 i2c_data[4]; /* Used only by write command, reserved in read. */
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_gnss_i2c);
+
+/**
+ * virtchnl_gnss_read_i2c_resp
+ * @i2c_data: Data returned from gnss console I2C read
+ *
+ * Structure returned by PF in response to VIRTCHNL_OP_GNSS_READ_I2C for
+ * GNSS Console I2C Read.
+ */
+struct virtchnl_gnss_read_i2c_resp {
+	u8 i2c_data[16];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_gnss_read_i2c_resp);
+
 /* Since VF messages are limited by u16 size, precalculate the maximum possible
  * values of nested elements in virtchnl structures that virtual channel can
  * possibly handle in a single message.
@@ -3500,6 +3605,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 		break;
 	case VIRTCHNL_OP_SYNCE_GET_HW_INFO:
 		break;
+	case VIRTCHNL_OP_GNSS_READ_I2C:
+		valid_len = sizeof(struct virtchnl_gnss_i2c);
+		break;
+	case VIRTCHNL_OP_GNSS_WRITE_I2C:
+		valid_len = sizeof(struct virtchnl_gnss_i2c);
+		break;
 	case VIRTCHNL_OP_ENABLE_QUEUES_V2:
 	case VIRTCHNL_OP_DISABLE_QUEUES_V2:
 		valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
-- 
2.25.1


  parent reply	other threads:[~2023-04-13  9:51 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  9:44 [PATCH 00/18] update idpf shared code Wenjing Qiao
2023-04-13  9:44 ` [PATCH 01/18] common/idpf: support flow subscription Wenjing Qiao
2023-04-21  8:40   ` [PATCH v2 00/15] update idpf shared code Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 01/15] common/idpf: remove virtchnl related " Wenjing Qiao
2023-04-24 11:52       ` Zhang, Qi Z
2023-04-26 10:22       ` [PATCH v3 00/15] update idpf base code Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 01/15] common/idpf/base: remove virtchnl related " Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 02/15] common/idpf/base: fix ctlq message send and receive Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 03/15] common/idpf/base: fix ITR register definitions for AVF Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 04/15] common/idpf/base: remove qregion struct variables Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 05/15] common/idpf/base: move OEM capability to the last bit Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 06/15] common/idpf/base: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 07/15] common/idpf/base: add virtchnl2 error codes Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 08/15] common/idpf/base: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 09/15] common/idpf/base: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 10/15] common/idpf/base: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 11/15] common/idpf/base: allocate static buffer at initialization Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 12/15] common/idpf/base: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 13/15] common/idpf/base: add/delete queue groups commands Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 14/15] common/idpf/base: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-26 10:22         ` [PATCH v3 15/15] common/idpf/base: update license and README Wenjing Qiao
2023-04-26 11:56           ` Zhang, Qi Z
2023-06-12 10:18           ` Thomas Monjalon
2023-04-26 12:40         ` [PATCH v3 00/15] update idpf base code Zhang, Qi Z
2023-04-21  8:40     ` [PATCH v2 02/15] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 03/15] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 04/15] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 05/15] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 06/15] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 07/15] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 08/15] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 09/15] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 10/15] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 11/15] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-24 12:15       ` Zhang, Qi Z
2023-04-21  8:40     ` [PATCH v2 12/15] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 13/15] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 14/15] common/idpf: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-21  8:40     ` [PATCH v2 15/15] common/idpf: update license and README Wenjing Qiao
2023-04-13  9:44 ` [PATCH 02/18] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-13  9:44 ` [PATCH 03/18] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-13  9:44 ` [PATCH 04/18] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-13  9:44 ` [PATCH 05/18] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-13  9:44 ` [PATCH 06/18] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-13  9:44 ` [PATCH 07/18] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-13  9:44 ` [PATCH 08/18] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-13  9:44 ` [PATCH 09/18] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-13  9:44 ` [PATCH 10/18] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-13  9:44 ` [PATCH 11/18] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-13  9:44 ` [PATCH 12/18] common/idpf: add SyncE support over VF Wenjing Qiao
2023-04-13  9:44 ` [PATCH 13/18] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-13  9:44 ` Wenjing Qiao [this message]
2023-04-13  9:44 ` [PATCH 15/18] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-13  9:45 ` [PATCH 16/18] common/idpf: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-13  9:45 ` [PATCH 17/18] common/idpf: fix cannot understand warnings Wenjing Qiao
2023-04-13  9:45 ` [PATCH 18/18] common/idpf: update license and README Wenjing Qiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230413094502.1714755-15-wenjing.qiao@intel.com \
    --to=wenjing.qiao@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=xuejun.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).