FreeBSD/sys/dev/nxge/xgehal/xgehal-mgmt.c
/**
 * xge_hal_mgmt_trace_read - Read trace buffer contents.
 * @buffer: Buffer to store the trace buffer contents.
 * @buf_size: Size of the buffer.
 * @offset: Offset in the internal trace buffer to read data.
 * @read_length: Size of the valid data in the buffer.
 *
 * Read  HAL trace buffer contents starting from the offset
 * upto the size of the buffer or till EOF is reached.
 *
 * Returns: XGE_HAL_OK - success.
 * XGE_HAL_EOF_TRACE_BUF - No more data in the trace buffer.
 *
 */
Read trace buffer contents.
@buffer: Buffer to store the trace buffer contents.
@buf_size: Size of the buffer.
@offset: Offset in the internal trace buffer to read data.
@read_length: Size of the valid data in the buffer.

Read  HAL trace buffer contents starting from the offset
upto the size of the buffer or till EOF is reached.

success.
XGE_HAL_EOF_TRACE_BUF - No more data in the trace buffer.
Read trace buffer contents . @buffer : Buffer to store the trace buffer contents . @buf_size : Size of the buffer . @offset : Offset in the internal trace buffer to read data . @read_length : Size of the valid data in the buffer . Read HAL trace buffer contents starting from the offset upto the size of the buffer or till EOF is reached . success . XGE_HAL_EOF_TRACE_BUF - No more data in the trace buffer .
xge_hal_status_e
xge_hal_mgmt_trace_read (char       *buffer,
	        unsigned    buf_size,
	        unsigned    *offset,
	        unsigned    *read_length)
{
	int data_offset;
	int start_offset;
	if ((g_xge_os_tracebuf == NULL) ||
	    (g_xge_os_tracebuf->offset == g_xge_os_tracebuf->size - 2)) {
	    return XGE_HAL_EOF_TRACE_BUF;
	}
	data_offset = g_xge_os_tracebuf->offset + 1;
	if  (*offset >= (unsigned)xge_os_strlen(g_xge_os_tracebuf->data +
	data_offset)) {
	    return XGE_HAL_EOF_TRACE_BUF;
	}
	xge_os_memzero(buffer, buf_size);
	start_offset  =  data_offset + *offset;
	*read_length = xge_os_strlen(g_xge_os_tracebuf->data +
	start_offset);
	if (*read_length  >=  buf_size) {
	    *read_length = buf_size - 1;
	}
	xge_os_memcpy(buffer, g_xge_os_tracebuf->data + start_offset,
	*read_length);
	*offset += *read_length;
	(*read_length) ++;
	return XGE_HAL_OK;
}
xge_hal_status_e xge_hal_mgmt_trace_read ( char * buffer , unsigned buf_size , unsigned * offset , unsigned * read_length ) { int data_offset ; int start_offset ; if ( ( g_xge_os_tracebuf == NULL ) || ( g_xge_os_tracebuf -> offset == g_xge_os_tracebuf -> size - 2 ) ) { return XGE_HAL_EOF_TRACE_BUF ; } data_offset = g_xge_os_tracebuf -> offset + 1 ; if ( * offset >= ( unsigned ) xge_os_strlen ( g_xge_os_tracebuf -> data + data_offset ) ) { return XGE_HAL_EOF_TRACE_BUF ; } xge_os_memzero ( buffer , buf_size ) ; start_offset = data_offset + * offset ; * read_length = xge_os_strlen ( g_xge_os_tracebuf -> data + start_offset ) ; if ( * read_length >= buf_size ) { * read_length = buf_size - 1 ; } xge_os_memcpy ( buffer , g_xge_os_tracebuf -> data + start_offset , * read_length ) ; * offset += * read_length ; ( * read_length ) ++ ; return XGE_HAL_OK ; }
xge_hal_mgmt_trace_read - Read trace buffer contents.
xge_hal_mgmt_trace_read - Read trace buffer contents .