Intel® IXP400 Software
Access-Layer Components: HSS-Access (IxHssAcc) API
Programmer’s Guide IXP400 Software Version 2.0 April 2005
Document Number: 252539, Revision: 007 209
Here is an example:
Usually, an Rx thread is created to handle the HSS packetized service, namely, to handle all the
callback functions registered with ixHssAccPktPortConnect(). The thread will be waiting for a
semaphore. When any one of the call back functions is executed by the HSS component, it will put
the information from IxHssAcc into a structure, and send a semaphore to the thread. Then the
callback function returns so that IxHssAcc can continues its own tasks. The Rx thread, after
receiving the semaphore, will wake up, take the parameters from the structure passed by the
callback function, and perform Rx data processing and error handling.
When data is received, rxCallback() is called. It passes the received data in the form of a IXP_BUF
to the client. The IXP_BUF passed back to the client could contain a chain of IXP_BUF, depending
on the packet size received. IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR() can be used to
get access to each of the IXP_BUF in the chained buffer, and IX_OSAL_MBUF_MDATA() can be
used to get access to each data value. The IXP_BUF is returned to the buffer pool by using
IX_OSAL_MBUF_POOL_PUT_CHAIN().
Here is an example:
rxCallback() also passes the packet status and the number of errors that NPE receives. The packet
status is used to determine if the packet received is good or bad, and the client can call function
ixHssAccLastErrorRetrievalInitiate() to initiate the retrieval of the last HSS error.
When the Rx buffer queue is running low, rxFreeLowCallback() is called. Then, the client can call
IX_OSAL_MBUF_POOL_GET() and ixHssAccPktPortRxFreeReplenish() to fill up the Rx queue
again.
// get a buffer
IX_OSAL_MBUF *rxBuffer;
rxBuffer = IX_OSAL_MBUF_POOL_GET(poolId);
//IxHssAcc component needs to know the capacity of the IXP_BUF
IX_OSAL_MBUF_MLEN(rxBuffer) = IX_HSSACC_CODELET_PKT_BUFSIZE;
// give the Rx buffer to the HssAcc component
status = ixHssAccPktPortRxFreeReplenish (hssPortId,
hdlcPortId, rxBuffer);
IX_OSAL_MBUF *buffer,
IX_OSAL_MBUF *rxBuffer;
// go through each buffer in the chained buffer
for (rxBuffer = buffer;
(rxBuffer != NULL) && (pktStatus == IX_HSSACC_PKT_OK);
rxBuffer = IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(rxBuffer))
for (wordIndex =0;wordIndex<(IX_OSAL_MBUF_MLEN(rxBuffer) / 4);
wordIndex++)
{ // get the values in the buffer IXP_BUF
value = ((UINT32 *)IX_OSAL_MBUF_MDATA(rxBuffer))[wordIndex];
}
// free the chained buffer
IX_OSAL_MBUF_POOL_PUT_CHAIN(buffer);