Linked list of packets

In my above-filter I allocate a single npkt_t and resend the same packet
(with a different time stamp) every milli-second. I found that if I sent the
above packet and different packet immediately after, every following time I
sent the timestamp packet it would be immediately followed by a garbage
packet. To further complicate debugging, this occurs with the el900 and
speedo driver, yet never happened with the pcnet driver. The explanation
seems to be that the ethernet driver set npkt.next when the two packets got
sent back-to-back, and when I later reused the packet the driver tried to
send two packets (even though the second no longer existed).

I was thinking of using npkt.next for my own purposes in my above-filter
(when I thought it was an unused field). Does the use of next by the
ethernet driver preclude this?

If I want to transmit multiple packets in quick succession, can I link them
together using the next field and send them down to the ethernet driver? Is
this supported by all network drivers?

When re-using a downward headed packet what fields need to be cleared?
Experimentally, I’ve found the following two must be cleared (otherwise
you blow your toes off): req_complete and next. Are there any others?

Thanks,
Shaun

Shaun Jackman <sjackman@nospam.vortek.com> wrote:

In my above-filter I allocate a single npkt_t and resend the same packet
(with a different time stamp) every milli-second. I found that if I sent the
above packet and different packet immediately after, every following time I
sent the timestamp packet it would be immediately followed by a garbage
packet. To further complicate debugging, this occurs with the el900 and
speedo driver, yet never happened with the pcnet driver. The explanation
seems to be that the ethernet driver set npkt.next when the two packets got
sent back-to-back, and when I later reused the packet the driver tried to
send two packets (even though the second no longer existed).

I was thinking of using npkt.next for my own purposes in my above-filter
(when I thought it was an unused field). Does the use of next by the
ethernet driver preclude this?

No. Down headed packets pass through each module in turn. While
in a particular module, it can use npkt->next. Before it passes it
on, it should NULL it out. I took a quick look at the speedo and
el900 code and they do use this but seem to NULL it out before releasing
the packet. You realize you can’t reuse the packet before your
tx_done() routine is called? What versions are you running?

If I want to transmit multiple packets in quick succession, can I link them
together using the next field and send them down to the ethernet driver? Is
this supported by all network drivers?

No. You need to send them one at a time.

When re-using a downward headed packet what fields need to be cleared?
Experimentally, I’ve found the following two must be cleared (otherwise
you blow your toes off): req_complete and next. Are there any others?

npkt->flags should be 0 for down headed packets.

-seanb

No. Down headed packets pass through each module in turn. While
in a particular module, it can use npkt->next. Before it passes it
on, it should NULL it out. I took a quick look at the speedo and
el900 code and they do use this but seem to NULL it out before releasing
the packet. You realize you can’t reuse the packet before your
tx_done() routine is called? What versions are you running?

I definitely wait until my tx_done() is called before I reuse the packet. I
mark the packet as used beforeI tx_down(), and clear the mark in my
tx_done() routine. I don’t reuse the packet until the mark is cleared. In
fact, my bug was fixed as soon as I added npkt->next = NULL to my tx_done()
routine. Note that I don’t use npkt->next myself at all. I am running QNX
6.1.0 with patchA.

Cheers,
Shaun

Shaun Jackman <sjackman@nospam.vortek.com> wrote:

No. Down headed packets pass through each module in turn. While
in a particular module, it can use npkt->next. Before it passes it
on, it should NULL it out. I took a quick look at the speedo and
el900 code and they do use this but seem to NULL it out before releasing
the packet. You realize you can’t reuse the packet before your
tx_done() routine is called? What versions are you running?

I definitely wait until my tx_done() is called before I reuse the packet. I
mark the packet as used beforeI tx_down(), and clear the mark in my
tx_done() routine. I don’t reuse the packet until the mark is cleared. In
fact, my bug was fixed as soon as I added npkt->next = NULL to my tx_done()
routine. Note that I don’t use npkt->next myself at all. I am running QNX
6.1.0 with patchA.

Yes, I see it in 6.1. Looks like it’s fixed in 6.2. It doesn’t hurt
to always null it out yourself though.

-seanb