packet memory allocation

In the thread `io-net bug on slow machine’ I saw the following comment:

** npkt_t: main hdr
** Nnpkt_done_t: 1 per module that add’s data to a down pkt (1 in this
** (tcpip uses 2, one for the tcp module & 1 for the converter)
** net_buf_t: 1 per cluster of iov’s (note this could be bigger than the
** structure. It contains an array of pointers as the last
element in the struct. One
** array element for each net_iov_t supported by this net_buf_t
** net_iov_t: we only need one iov for this application
** ether_pkt_t: DATA, what actually goes out on the wire
npkt = bcp->npi->alloc_down_npkt(bcp->reg_hdl,
sizeof(npkt_t) + 1
sizeof(npkt_done_t) // 1st struct (and 1.a)

  • sizeof(net_buf_t) // 2nd struct
  • sizeof(net_iov_t) // 3rd struct
  • sizeof(ether_pkt_t), // data
    (void **)&nbp); // 3rd struct

I’ve been doing the following, assuming that alloc_down_pkt() allocated the
npkt_t and npkt_done_t to the npkt pointer implicitly. This is my
understanding: the size parameter allocates a chunk of memory to the nb
parameter. The npkt pointer is allocated a constant amount of memory which
is separate from nb. Is this correct?
npkt = ion->alloc_down_pkt(
sizeof( net_buf_t) + sizeof( net_iov_t)

  • sizeof( VORNET_PACKET),
    (void **)&nb );