Skip to content

Commit

Permalink
[Silabs]restructuring low level output api (#29863)
Browse files Browse the repository at this point in the history
* restructuring low level output api

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
Thirsrin and restyled-commits authored Oct 19, 2023
1 parent a9b8be8 commit e1d34ea
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/platform/silabs/efr32/wifi/ethernetif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,24 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
void * packet;
#endif
struct pbuf * q;
uint16_t framelength;
uint16_t framelength = 0;
uint16_t datalength = 0;
#ifdef WIFI_DEBUG_ENABLED
SILABS_LOG("LWIP : low_level_output");
#endif
if (xSemaphoreTake(ethout_sem, portMAX_DELAY) != pdTRUE)
{
return ERR_IF;
}
/* Calculate total packet size */
for (q = p, framelength = 0; q != NULL; q = q->next)
{
framelength += q->len;
}
if (framelength < LWIP_FRAME_ALIGNMENT)
{
framelength = LWIP_FRAME_ALIGNMENT;
}
#ifdef WIFI_DEBUG_ENABLED
SILABS_LOG("EN-RSI: Output");
#endif
Expand All @@ -377,7 +387,7 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
}
/* Confirm if packet is allocated */
#if (SIWX_917 | EXP_BOARD)
status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + p->len,
status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + framelength,
SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS);
VERIFY_STATUS_AND_RETURN(status);
if (packet == NULL)
Expand All @@ -402,29 +412,32 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p)
b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13]);
#endif
/* Generate the packet */
for (q = p, framelength = 0; q != NULL; q = q->next)
for (q = p, datalength = 0; q != NULL; q = q->next)
{
wfx_rsi_pkt_add_data(packet, (uint8_t *) (q->payload), (uint16_t) q->len, framelength);
framelength += q->len;
wfx_rsi_pkt_add_data(packet, (uint8_t *) (q->payload), (uint16_t) q->len, datalength);
datalength += q->len;
}
if (framelength < LWIP_FRAME_ALIGNMENT)
if (datalength < LWIP_FRAME_ALIGNMENT)
{
/* Add junk data to the end for frame alignment if framelength is less than 60 */
wfx_rsi_pkt_add_data(packet, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - framelength, framelength);
wfx_rsi_pkt_add_data(packet, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - datalength, datalength);
}
#ifdef WIFI_DEBUG_ENABLED
SILABS_LOG("EN-RSI: Sending %d", framelength);
#endif

/* forward the generated packet to RSI to
* send the data over wifi network
*/
#if (SIWX_917 | EXP_BOARD)
packet->length = p->len & 0xFFF;
packet->length = framelength & 0xFFF;
packet->command = RSI_SEND_RAW_DATA;
if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, 1000))
#else
/* forward the generated packet to RSI to
* send the data over wifi network
*/
if (wfx_rsi_send_data(packet, framelength))
if (wfx_rsi_send_data(packet, datalength))
#endif
{
SILABS_LOG("*ERR*EN-RSI:Send fail");
Expand Down

0 comments on commit e1d34ea

Please sign in to comment.