Skip to content
Merged
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
14 changes: 12 additions & 2 deletions source/portable/NetworkInterface/DriverSAM/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,22 @@ static BaseType_t prvSAM_NetworkInterfaceOutput( NetworkInterface_t * pxInterfac
if( ulResult != GMAC_OK )
{
TX_STAT_INCREMENT( tx_write_fail );

/* On a successful write to GMAC, the ownership of the TX descriptor will eventually get returned back to the network
* driver and prvEMACHandlerTask will give back the xTXDescriptorSemaphore counting semaphore. In this case however,
* writing to the GMAC failed, so there will be no EMAC_IF_TX_EVENT sent to prvEMACHandlerTask and the counting
* semaphore will not be given back. Give it back now. */
xSemaphoreGive( xTXDescriptorSemaphore );
}

#if ( ipconfigZERO_COPY_TX_DRIVER != 0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, one remark: when sending was not possible, the ownership of the packet has not been transferred to the interface, hence the packet must be released "manually":

 ulResult = gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, ulTransmitSize );
 
 if( ulResult != GMAC_OK )
 {
     TX_STAT_INCREMENT( tx_write_fail );
 
     xSemaphoreGive( xTXDescriptorSemaphore );
 }
 
 #if ( ipconfigZERO_COPY_TX_DRIVER != 0 )
 {
-    /* Confirm that the pxDescriptor may be kept by the driver. */
+    if( ulResult == GMAC_OK )
+    {
+        /* The message was send in a zero-copy way.
+         * It will be released after a succeful transmission. 
+         */
         bReleaseAfterSend = pdFALSE;
+    }
 }
 #endif /* ipconfigZERO_COPY_TX_DRIVER */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see.... On an error, The network buffer was never handed over to hardware so we allow for it to be released.
Thanks, I'll add that.

{
/* Confirm that the pxDescriptor may be kept by the driver. */
bReleaseAfterSend = pdFALSE;
if( ulResult == GMAC_OK )
{
/* The message was send in a zero-copy way.
* It will be released after a successful transmission. */
bReleaseAfterSend = pdFALSE;
}
}
#endif /* ipconfigZERO_COPY_TX_DRIVER */
/* Not interested in a call-back after TX. */
Expand Down