Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - allocating memory for mbuf: (3 Items)
   
allocating memory for mbuf  
Hi ,
   1. Do we neet to just use malloc to allocate memory for mbuf?  In io-net there are inbuilt functions on io-net 
structure for allocation and free. 

2. Since io-net is not available now for 6.4.0 and above, we don't have to use iov which was part of io-net for porting 
to io-pkt right?

3. At the porting point where I am right now makes me feel, that  the _iopkt_self structure usage in io-pkt is very 
minimal compared to _io_net_self usage in io-net. Even though we are using_iopkt_self struct in the entry function, 
looks like most of the functionality is for the thread handling.  

4. I have around 512 bytes of data to read from stack and do my modification and then put back on stack to send it to 
other machine. From high level its very simple, but when I looking at the structure usage, its getting more entangled in
 other complex manipulations. Can any suggest simple steps to achive this using the io-pkt features and functionality.

Thanks
Vinod


Re: allocating memory for mbuf  
On Tue, Jan 19, 2010 at 08:28:16PM -0500, Vinod Kolapuram wrote:
> Hi ,
>    1. Do we neet to just use malloc to allocate memory for mbuf?  In io-net there are inbuilt functions on io-net 
structure for allocation and free. 

No, malloc doesn't provide memory that is safe for packet buffers, use
m_get(), m_gethdr() or m_getcl().  For 512 bytes you'll probably need
a cluster.

> 
> 2. Since io-net is not available now for 6.4.0 and above, we don't have to use iov which was part of io-net for 
porting to io-pkt right?

This is vague.  There's various iovs in both io-net and io-pkt.

> 
> 3. At the porting point where I am right now makes me feel, that  the _iopkt_self structure usage in io-pkt is very 
minimal compared to _io_net_self usage in io-net. Even though we are using_iopkt_self struct in the entry function, 
looks like most of the functionality is for the thread handling.  
> 
> 4. I have around 512 bytes of data to read from stack and do my modification and then put back on stack to send it to 
other machine. From high level its very simple, but when I looking at the structure usage, its getting more entangled in
 other complex manipulations. Can any suggest simple steps to achive this using the io-pkt features and functionality.

There's various ways to do this.  The most portable would be with
userland sockets.


Regards,

-seanb
Re: allocating memory for mbuf  
Hi Sean,
            I will be using nw_pthread_create() , I was looking at some implementations as suggested by the website for 
porting and I see that there is a init function as 6th argument, where 
wtp is intialized and on it "wtp->quiesce_callout" is called for a user specific function which basically will call "
MsgSendPulse().

Is it a must to have a init function. What if I put all NULLs to the extra last 3  arugments in nw_pthread_create()?

And I have a question regarding the iov_t. 
The existing implementation for io-net was done using iov now I am trying to port to io-pkt. Do I need to use iov or 
just copy the address of my data to mbuf to send it across to other machine using "if_output()" funtion available on 
ifnet struct. 
I am thinking mbuf will take care of sending it in its own format and on the other end when mbuf is received I will have
 a "PFIL_IN" hook which gets the mbuf content.

The below is the structs of iov on io-net.h file

typedef struct _net_iovec net_iov_t;

struct _net_iovec {
	void    *iov_base;
	paddr_t  iov_phys;
	size_t   iov_len;
};


typedef struct _net_buf net_buf_t;

struct _net_buf {
	TAILQ_ENTRY(_net_buf) ptrs;
	int niov;
	net_iov_t *net_iov;
};


For "io-pkt" implementation I have the iov_t on the nw_stk_ctl struct  in nw_datastruct.h . 

I am new to QNX, is it a must to use iov to send and receive data.

Thanks
Vinod