From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <marcinx.hajkowski@intel.com>
Received: from mga17.intel.com (mga17.intel.com [192.55.52.151])
 by dpdk.org (Postfix) with ESMTP id DB66D1B4EB
 for <dev@dpdk.org>; Wed,  3 Apr 2019 19:16:20 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 03 Apr 2019 10:16:20 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="161086719"
Received: from mhajkowx-mobl.ger.corp.intel.com ([10.104.116.180])
 by fmsmga001.fm.intel.com with ESMTP; 03 Apr 2019 10:16:19 -0700
From: Hajkowski <marcinx.hajkowski@intel.com>
To: david.hunt@intel.com
Cc: dev@dpdk.org,
	Marcin Hajkowski <marcinx.hajkowski@intel.com>
Date: Wed,  3 Apr 2019 19:15:57 +0200
Message-Id: <20190403171601.9788-2-marcinx.hajkowski@intel.com>
X-Mailer: git-send-email 2.20.1.windows.1
In-Reply-To: <20190403171601.9788-1-marcinx.hajkowski@intel.com>
References: <20190403171601.9788-1-marcinx.hajkowski@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH 1/4] power: extend guest channel for query freq.
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 03 Apr 2019 17:16:21 -0000

From: Marcin Hajkowski <marcinx.hajkowski@intel.com>

Extend incoming packet reading API with new packet
type which carries CPU frequencies.

Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
---
 lib/librte_power/channel_commands.h | 21 +++++++++++++++++++++
 lib/librte_power/guest_channel.c    | 27 ++++++++++++++++-----------
 lib/librte_power/guest_channel.h    | 21 ++++++++++++++++-----
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/channel_commands.h
index 33fd53a6d..ce587283c 100644
--- a/lib/librte_power/channel_commands.h
+++ b/lib/librte_power/channel_commands.h
@@ -15,6 +15,8 @@ extern "C" {
 /* Maximum number of channels per VM */
 #define CHANNEL_CMDS_MAX_VM_CHANNELS 64
 
+/* --- Incoming messages --- */
+
 /* Valid Commands */
 #define CPU_POWER               1
 #define CPU_POWER_CONNECT       2
@@ -29,10 +31,19 @@ extern "C" {
 #define CPU_POWER_ENABLE_TURBO  5
 #define CPU_POWER_DISABLE_TURBO 6
 
+/* CPU Power Queries */
+#define CPU_POWER_QUERY_FREQ_LIST  7
+#define CPU_POWER_QUERY_FREQ       8
+
+/* --- Outgoing messages --- */
+
 /* Generic Power Command Response */
 #define CPU_POWER_CMD_ACK       1
 #define CPU_POWER_CMD_NACK      2
 
+/* CPU Power Query Responses */
+#define CPU_POWER_FREQ_LIST     3
+
 #define HOURS 24
 
 #define MAX_VFS 10
@@ -85,6 +96,16 @@ struct channel_packet {
 	struct t_boost_status t_boost_status;
 };
 
+struct channel_packet_freq_list {
+	uint64_t resource_id; /**< core_num, device */
+	uint32_t unit;        /**< scale down/up/min/max */
+	uint32_t command;     /**< Power, IO, etc */
+	char vm_name[VM_MAX_NAME_SZ];
+
+	uint32_t freq_list[MAX_VCPU_PER_VM];
+	uint8_t num_vcpu;
+};
+
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c
index 888423891..439cd2f38 100644
--- a/lib/librte_power/guest_channel.c
+++ b/lib/librte_power/guest_channel.c
@@ -129,13 +129,15 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
 	return guest_channel_send_msg(pkt, lcore_id);
 }
 
-int power_guest_channel_read_msg(struct channel_packet *pkt,
-			unsigned int lcore_id)
+int power_guest_channel_read_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id)
 {
 	int ret;
 	struct pollfd fds;
-	void *buffer = pkt;
-	int buffer_len = sizeof(*pkt);
+
+	if (pkt_len == 0 || pkt == NULL)
+		return -1;
 
 	fds.fd = global_fds[lcore_id];
 	fds.events = POLLIN;
@@ -161,29 +163,32 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
 		return -1;
 	}
 
-	while (buffer_len > 0) {
+	while (pkt_len > 0) {
 		ret = read(global_fds[lcore_id],
-				buffer, buffer_len);
+				pkt, pkt_len);
+
 		if (ret < 0) {
 			if (errno == EINTR)
 				continue;
 			return -1;
 		}
+
 		if (ret == 0) {
 			RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n");
 			return -1;
 		}
-		buffer = (char *)buffer + ret;
-		buffer_len -= ret;
+		pkt = (char *)pkt + ret;
+		pkt_len -= ret;
 	}
 
 	return 0;
 }
 
-int rte_power_guest_channel_receive_msg(struct channel_packet *pkt,
-			unsigned int lcore_id)
+int rte_power_guest_channel_receive_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id)
 {
-	return power_guest_channel_read_msg(pkt, lcore_id);
+	return power_guest_channel_read_msg(pkt, pkt_len, lcore_id);
 }
 
 void
diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h
index 7c385df39..473901547 100644
--- a/lib/librte_power/guest_channel.h
+++ b/lib/librte_power/guest_channel.h
@@ -17,6 +17,7 @@ extern "C" {
  *
  * @param path
  *  The path to the serial device on the filesystem
+ *
  * @param lcore_id
  *  lcore_id.
  *
@@ -73,7 +74,11 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
  * from the host endpoint.
  *
  * @param pkt
- *  Pointer to a populated struct channel_packet
+ *  Pointer to channel_packet or
+ *  channel_packet_freq_list struct.
+ *
+ * @param pkt_len
+ *  Size of expected data packet.
  *
  * @param lcore_id
  *  lcore_id.
@@ -82,7 +87,8 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
  *  - 0 on success.
  *  - Negative on error.
  */
-int power_guest_channel_read_msg(struct channel_packet *pkt,
+int power_guest_channel_read_msg(void *pkt,
+		size_t pkt_len,
 		unsigned int lcore_id);
 
 /**
@@ -90,7 +96,11 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
  * from the host endpoint.
  *
  * @param pkt
- *  Pointer to a populated struct channel_packet
+ *  Pointer to channel_packet or
+ *  channel_packet_freq_list struct.
+ *
+ * @param pkt_len
+ *  Size of expected data packet.
  *
  * @param lcore_id
  *  lcore_id.
@@ -100,8 +110,9 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
  *  - Negative on error.
  */
 int __rte_experimental
-rte_power_guest_channel_receive_msg(struct channel_packet *pkt,
-			unsigned int lcore_id);
+rte_power_guest_channel_receive_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id);
 
 #ifdef __cplusplus
 }
-- 
2.17.2

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id CBF74A0679
	for <public@inbox.dpdk.org>; Wed,  3 Apr 2019 19:17:09 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 13A261B53A;
	Wed,  3 Apr 2019 19:16:37 +0200 (CEST)
Received: from mga17.intel.com (mga17.intel.com [192.55.52.151])
 by dpdk.org (Postfix) with ESMTP id DB66D1B4EB
 for <dev@dpdk.org>; Wed,  3 Apr 2019 19:16:20 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 03 Apr 2019 10:16:20 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="161086719"
Received: from mhajkowx-mobl.ger.corp.intel.com ([10.104.116.180])
 by fmsmga001.fm.intel.com with ESMTP; 03 Apr 2019 10:16:19 -0700
From: Hajkowski <marcinx.hajkowski@intel.com>
To: david.hunt@intel.com
Cc: dev@dpdk.org,
	Marcin Hajkowski <marcinx.hajkowski@intel.com>
Date: Wed,  3 Apr 2019 19:15:57 +0200
Message-Id: <20190403171601.9788-2-marcinx.hajkowski@intel.com>
X-Mailer: git-send-email 2.20.1.windows.1
In-Reply-To: <20190403171601.9788-1-marcinx.hajkowski@intel.com>
References: <20190403171601.9788-1-marcinx.hajkowski@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH 1/4] power: extend guest channel for query freq.
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190403171557.8ydLK5deNVZHZzhdWu_YUzyDgz8J2e17YYYrlJxRQhw@z>

From: Marcin Hajkowski <marcinx.hajkowski@intel.com>

Extend incoming packet reading API with new packet
type which carries CPU frequencies.

Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
---
 lib/librte_power/channel_commands.h | 21 +++++++++++++++++++++
 lib/librte_power/guest_channel.c    | 27 ++++++++++++++++-----------
 lib/librte_power/guest_channel.h    | 21 ++++++++++++++++-----
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/channel_commands.h
index 33fd53a6d..ce587283c 100644
--- a/lib/librte_power/channel_commands.h
+++ b/lib/librte_power/channel_commands.h
@@ -15,6 +15,8 @@ extern "C" {
 /* Maximum number of channels per VM */
 #define CHANNEL_CMDS_MAX_VM_CHANNELS 64
 
+/* --- Incoming messages --- */
+
 /* Valid Commands */
 #define CPU_POWER               1
 #define CPU_POWER_CONNECT       2
@@ -29,10 +31,19 @@ extern "C" {
 #define CPU_POWER_ENABLE_TURBO  5
 #define CPU_POWER_DISABLE_TURBO 6
 
+/* CPU Power Queries */
+#define CPU_POWER_QUERY_FREQ_LIST  7
+#define CPU_POWER_QUERY_FREQ       8
+
+/* --- Outgoing messages --- */
+
 /* Generic Power Command Response */
 #define CPU_POWER_CMD_ACK       1
 #define CPU_POWER_CMD_NACK      2
 
+/* CPU Power Query Responses */
+#define CPU_POWER_FREQ_LIST     3
+
 #define HOURS 24
 
 #define MAX_VFS 10
@@ -85,6 +96,16 @@ struct channel_packet {
 	struct t_boost_status t_boost_status;
 };
 
+struct channel_packet_freq_list {
+	uint64_t resource_id; /**< core_num, device */
+	uint32_t unit;        /**< scale down/up/min/max */
+	uint32_t command;     /**< Power, IO, etc */
+	char vm_name[VM_MAX_NAME_SZ];
+
+	uint32_t freq_list[MAX_VCPU_PER_VM];
+	uint8_t num_vcpu;
+};
+
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c
index 888423891..439cd2f38 100644
--- a/lib/librte_power/guest_channel.c
+++ b/lib/librte_power/guest_channel.c
@@ -129,13 +129,15 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
 	return guest_channel_send_msg(pkt, lcore_id);
 }
 
-int power_guest_channel_read_msg(struct channel_packet *pkt,
-			unsigned int lcore_id)
+int power_guest_channel_read_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id)
 {
 	int ret;
 	struct pollfd fds;
-	void *buffer = pkt;
-	int buffer_len = sizeof(*pkt);
+
+	if (pkt_len == 0 || pkt == NULL)
+		return -1;
 
 	fds.fd = global_fds[lcore_id];
 	fds.events = POLLIN;
@@ -161,29 +163,32 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
 		return -1;
 	}
 
-	while (buffer_len > 0) {
+	while (pkt_len > 0) {
 		ret = read(global_fds[lcore_id],
-				buffer, buffer_len);
+				pkt, pkt_len);
+
 		if (ret < 0) {
 			if (errno == EINTR)
 				continue;
 			return -1;
 		}
+
 		if (ret == 0) {
 			RTE_LOG(ERR, GUEST_CHANNEL, "Expected more data, but connection has been closed.\n");
 			return -1;
 		}
-		buffer = (char *)buffer + ret;
-		buffer_len -= ret;
+		pkt = (char *)pkt + ret;
+		pkt_len -= ret;
 	}
 
 	return 0;
 }
 
-int rte_power_guest_channel_receive_msg(struct channel_packet *pkt,
-			unsigned int lcore_id)
+int rte_power_guest_channel_receive_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id)
 {
-	return power_guest_channel_read_msg(pkt, lcore_id);
+	return power_guest_channel_read_msg(pkt, pkt_len, lcore_id);
 }
 
 void
diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h
index 7c385df39..473901547 100644
--- a/lib/librte_power/guest_channel.h
+++ b/lib/librte_power/guest_channel.h
@@ -17,6 +17,7 @@ extern "C" {
  *
  * @param path
  *  The path to the serial device on the filesystem
+ *
  * @param lcore_id
  *  lcore_id.
  *
@@ -73,7 +74,11 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
  * from the host endpoint.
  *
  * @param pkt
- *  Pointer to a populated struct channel_packet
+ *  Pointer to channel_packet or
+ *  channel_packet_freq_list struct.
+ *
+ * @param pkt_len
+ *  Size of expected data packet.
  *
  * @param lcore_id
  *  lcore_id.
@@ -82,7 +87,8 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
  *  - 0 on success.
  *  - Negative on error.
  */
-int power_guest_channel_read_msg(struct channel_packet *pkt,
+int power_guest_channel_read_msg(void *pkt,
+		size_t pkt_len,
 		unsigned int lcore_id);
 
 /**
@@ -90,7 +96,11 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
  * from the host endpoint.
  *
  * @param pkt
- *  Pointer to a populated struct channel_packet
+ *  Pointer to channel_packet or
+ *  channel_packet_freq_list struct.
+ *
+ * @param pkt_len
+ *  Size of expected data packet.
  *
  * @param lcore_id
  *  lcore_id.
@@ -100,8 +110,9 @@ int power_guest_channel_read_msg(struct channel_packet *pkt,
  *  - Negative on error.
  */
 int __rte_experimental
-rte_power_guest_channel_receive_msg(struct channel_packet *pkt,
-			unsigned int lcore_id);
+rte_power_guest_channel_receive_msg(void *pkt,
+		size_t pkt_len,
+		unsigned int lcore_id);
 
 #ifdef __cplusplus
 }
-- 
2.17.2