This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Pointer modification transmitting small chained packets

Hi,

In the Ethernet examples in StarterWare for AM335x there is the following code sequence in the file cpswif.c (Procedure "cpswif_output"):

  /**
   * Adjust the packet length if less than minimum required.
   */
  if(p->tot_len < MIN_PKT_LEN) {
    p->tot_len = MIN_PKT_LEN;

    while(p->next != NULL) {
      p->next->tot_len = p->tot_len - p->len;
      p = p->next;
    }

    /* Adjust the length of the last pbuf. (contents - don't care) */
    p->len = p->tot_len;
  }

This sequence does modify the pointer "p" in the case of short chained packet needs to be transmitted. My opinion is that this code sequence should not modify the pointer "p" but instead should use a temporary pointer to do this.

Any feedback is appreciated. Thanks.
Patrick

  • I'd guess allocated memory size of p->payload is always MIN_PKT_LEN so that in this case just some crap/old data would be submitted which don't care. But to be sure I'd recommend to ask in lwIP mailing list at https://lists.nongnu.org/mailman/listinfo/lwip-users

  • In fact it's not. If, for example ARP protocoll needs to be send, packets are always shorter and they need to be padded. The question is if there are small chained packets that can be smaller than MIN_PKT_LEN. Otherwise the piece of code that modify the pointer is just not needed.
    There is an other post in the Hercules forum describing a similar problem (maybe that code is safer):

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/255152.aspx

    Maybe a lwIP expert from TI can give some advice.

  • Any news on this topic? Anyone from TI responsible for StarterWare Ethernet examples?

    Thanks,
    Patrick