Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Verified Commit f3f1a78f authored by Ayush Singh's avatar Ayush Singh
Browse files

Remove use of pad bytes from AP


- Make things spec compliant on AP side

Signed-off-by: default avatarAyush Singh <ayushdevel1325@gmail.com>
parent 260b86b5
Branches
1 merge request!3Single Socket Multiplex
......@@ -33,10 +33,11 @@ void ap_deinit(void);
* Submit message received by AP from transport
*
* @param greybus message
* @param cport_id
*
* @return 0 if successful, negative in case of error
*/
int ap_rx_submit(struct gb_message *msg);
int ap_rx_submit(struct gb_message *msg, uint16_t cport_id);
/*
* Get AP Interface
......
......@@ -81,10 +81,11 @@ int hdlc_rx_finish(uint32_t written);
*
* @param Greybus message
*/
static inline int gb_message_hdlc_send(const struct gb_message *msg)
static inline int gb_message_hdlc_send(struct gb_message *msg, uint16_t cport)
{
char buffer[HDLC_MAX_BLOCK_SIZE];
memcpy(msg->header.pad, &sys_cpu_to_le16(cport), sizeof(cport));
memcpy(buffer, &msg->header, sizeof(struct gb_operation_msg_hdr));
memcpy(&buffer[sizeof(struct gb_operation_msg_hdr)], msg->payload, gb_message_payload_len(msg));
......
......@@ -15,9 +15,7 @@ static int ap_inf_write(struct gb_controller *ctrl, struct gb_message *msg, uint
{
ARG_UNUSED(ctrl);
/* We use padding to pass AP Cport */
gb_message_pad_write(msg, cport_id);
gb_message_hdlc_send(msg);
gb_message_hdlc_send(msg, cport_id);
gb_message_dealloc(msg);
return 0;
}
......@@ -74,10 +72,8 @@ struct gb_interface *ap_init(void)
return &intf;
}
int ap_rx_submit(struct gb_message *msg)
int ap_rx_submit(struct gb_message *msg, uint16_t cport_id)
{
uint16_t cport_id = gb_message_pad_read(msg);
if (cport_id >= AP_MAX_NODES) {
return -1;
}
......
......@@ -86,9 +86,8 @@ static int hdlc_process_greybus_frame(const char *buffer, size_t buffer_len)
LOG_ERR("Failed to allocate greybus message");
return -1;
}
memcpy(msg->header.pad, hdr->pad, sizeof(uint16_t));
memcpy(msg->payload, &buffer[sizeof(struct gb_operation_msg_hdr)], gb_message_payload_len(msg));
ret = ap_rx_submit(msg);
ret = ap_rx_submit(msg, sys_get_le16(hdr->pad));
if (ret < 0) {
LOG_ERR("Failed add message to AP Queue");
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment