Skip to content

Fix host cdc ecm packet pool instance wait #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
*
* Copyright (c) 2024 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
*
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** USBX Component */
/** */
/** CDC_ECM Class */
/** */
Expand All @@ -30,32 +30,32 @@


#if !defined(UX_HOST_STANDALONE)
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_thread PORTABLE C */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_thread PORTABLE C */
/* 6.2.0 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* */
/* This is the CDC ECM thread that monitors the link change flag, */
/* receives data from the device, and passes the data to the NetX-USB */
/* broker. */
/* */
/* INPUT */
/* */
/* cdc_ecm CDC ECM instance */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* broker. */
/* */
/* INPUT */
/* */
/* cdc_ecm CDC ECM instance */
/* */
/* OUTPUT */
/* */
/* Completion Status */
/* */
/* CALLS */
/* */
/* _ux_host_class_cdc_ecm_transmit_queue_clean */
/* Clean transmit queue */
/* _ux_host_stack_transfer_request Transfer request */
Expand All @@ -67,15 +67,15 @@
/* _ux_network_driver_packet_received Process received packet */
/* nx_packet_allocate Allocate NetX packet */
/* nx_packet_release Free NetX packet */
/* */
/* CALLED BY */
/* */
/* CDC ECM class initialization */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* */
/* CALLED BY */
/* */
/* CDC ECM class initialization */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* prefixed UX to MS_TO_TICK, */
Expand Down Expand Up @@ -114,9 +114,9 @@ ULONG packet_buffer_size;
/* Cast the parameter passed in the thread into the cdc_ecm pointer. */
UX_THREAD_EXTENSION_PTR_GET(cdc_ecm, UX_HOST_CLASS_CDC_ECM, parameter)

/* Loop forever waiting for changes signaled through the semaphore. */
/* Loop forever waiting for changes signaled through the semaphore. */
while (1)
{
{

/* Wait for the semaphore to be put by the cdc_ecm interrupt event. */
_ux_host_semaphore_get_norc(&cdc_ecm -> ux_host_class_cdc_ecm_interrupt_notification_semaphore, UX_WAIT_FOREVER);
Expand All @@ -130,10 +130,10 @@ ULONG packet_buffer_size;

/* Communicate the state with the network driver. */
_ux_network_driver_link_up(cdc_ecm -> ux_host_class_cdc_ecm_network_handle);

/* As long as we are connected, configured and link up ... do some work.... */
while ((cdc_ecm -> ux_host_class_cdc_ecm_link_state == UX_HOST_CLASS_CDC_ECM_LINK_STATE_UP) &&
(cdc_ecm -> ux_host_class_cdc_ecm_device -> ux_device_state == UX_DEVICE_CONFIGURED))
(cdc_ecm -> ux_host_class_cdc_ecm_device -> ux_device_state == UX_DEVICE_CONFIGURED))
{

/* Check if we have packet pool available. */
Expand All @@ -154,7 +154,7 @@ ULONG packet_buffer_size;
{

/* IP instance is not available, wait for application to attach the interface. */
_ux_utility_delay_ms(UX_MS_TO_TICK(UX_HOST_CLASS_CDC_ECM_PACKET_POOL_INSTANCE_WAIT));
_ux_utility_delay_ms(UX_HOST_CLASS_CDC_ECM_PACKET_POOL_INSTANCE_WAIT);
}
continue;
}
Expand All @@ -168,7 +168,7 @@ ULONG packet_buffer_size;

/* Adjust the prepend pointer to take into account the non 3 bit alignment of the ethernet header. */
packet -> nx_packet_prepend_ptr += sizeof(USHORT);

/* We have a packet. Link this packet to the reception transfer request on the bulk in endpoint. */
transfer_request = &cdc_ecm -> ux_host_class_cdc_ecm_bulk_in_endpoint -> ux_endpoint_transfer_request;

Expand Down Expand Up @@ -206,18 +206,18 @@ ULONG packet_buffer_size;
#endif
{

/* Set the data pointer. */
/* Set the data pointer. */
transfer_request -> ux_transfer_request_data_pointer = packet -> nx_packet_prepend_ptr;

}

/* And length. */
transfer_request -> ux_transfer_request_requested_length = UX_HOST_CLASS_CDC_ECM_NX_PAYLOAD_SIZE;
transfer_request -> ux_transfer_request_actual_length = 0;

/* Store the packet that owns this transaction. */
transfer_request -> ux_transfer_request_user_specific = packet;

/* Reset the queue pointer of this packet. */
packet -> nx_packet_queue_next = UX_NULL;

Expand All @@ -235,7 +235,7 @@ ULONG packet_buffer_size;
cdc_ecm -> ux_host_class_cdc_ecm_bulk_in_transfer_check_and_arm_in_process = UX_FALSE;
if (cdc_ecm -> ux_host_class_cdc_ecm_bulk_in_transfer_waiting_for_check_and_arm_to_finish == UX_TRUE)
_ux_host_semaphore_put(&cdc_ecm -> ux_host_class_cdc_ecm_bulk_in_transfer_waiting_for_check_and_arm_to_finish_semaphore);

/* Check if the transaction was armed successfully. */
if (status == UX_SUCCESS)
{
Expand Down Expand Up @@ -280,13 +280,13 @@ ULONG packet_buffer_size;
{

/* Get the packet length. */
packet -> nx_packet_length = transfer_request -> ux_transfer_request_actual_length;
/* Adjust the prepend, length, and append fields. */
packet -> nx_packet_length = transfer_request -> ux_transfer_request_actual_length;

/* Adjust the prepend, length, and append fields. */
packet -> nx_packet_append_ptr =
packet->nx_packet_prepend_ptr + transfer_request -> ux_transfer_request_actual_length;
}

/* Send that packet to the NetX USB broker. */
_ux_network_driver_packet_received(cdc_ecm -> ux_host_class_cdc_ecm_network_handle, packet);
}
Expand Down Expand Up @@ -345,6 +345,6 @@ ULONG packet_buffer_size;
/* Set the link state. */
cdc_ecm -> ux_host_class_cdc_ecm_link_state = UX_HOST_CLASS_CDC_ECM_LINK_STATE_DOWN;
}
}
}
}
#endif