struct channel_packet pkt;
int ret;
- ret = rte_power_guest_channel_receive_msg(&pkt, lcore_id);
+ ret = rte_power_guest_channel_receive_msg(&pkt, sizeof pkt, lcore_id);
if (ret < 0)
return -1;
#include <stdint.h>
#include <stdbool.h>
+/* --- Incoming messages --- */
+
/* Valid Commands */
#define CPU_POWER 1
#define CPU_POWER_CONNECT 2
#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
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
}
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;
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
*
* @param path
* The path to the serial device on the filesystem
+ *
* @param lcore_id
* lcore_id.
*
* 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.
* - 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);
/**
* 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.
*/
__rte_experimental
int
-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
}