CloudNativeDataPlane / cndp

Cloud Native Data Plane (CNDP) is a collection of user space libraries to accelerate packet processing for cloud applications using AF_XDP sockets as the primary I/O..
BSD 3-Clause "New" or "Revised" License
90 stars 32 forks source link

chnl: add chnl_port to get port from connected channel #388

Closed jalalmostafa closed 4 months ago

jalalmostafa commented 4 months ago

This PR adds a new chnl_port API function, allowing us to know which port this channel is bound to. It is important to allocate mbufs when sending data e.g.

pktmbuf_t* bufs[256];
int portid = chnl_port(cd);
pktdev_buf_alloc(portid, bufs, burst);
chnl_send(cd, bufs, burst);

This can be easily done as the PCB entry will be linked to a specific port (interface and queue) in the FIB when the connection has been established chnl_accept or chnl_connect has finished.