/* @queue: Input queue to setup RED on (0-7) @pass_thresh: Packets will begin slowly dropping when there are less than this many packet buffers free in FPA 0. @drop_thresh: All incomming packets will be dropped when there are less than this many free packet buffers in FPA 0. Returns Zero on success. Negative on failure  */
int cvmx_helper_setup_red_queue(int queue, int pass_thresh, int drop_thresh)
/* @queue: Input queue to setup RED on (0-7) @pass_thresh: Packets will begin slowly dropping when there are less than this many packet buffers free in FPA 0. @drop_thresh: All incomming packets will be dropped when there are less than this many free packet buffers in FPA 0. Returns Zero on success. Negative on failure  */
int cvmx_helper_setup_red_queue(int queue, int pass_thresh, int drop_thresh)
{
	union cvmx_ipd_qosx_red_marks red_marks;
	union cvmx_ipd_red_quex_param red_param;
	red_marks.u64 = 0;
	red_marks.s.drop = drop_thresh;
	red_marks.s.pass = pass_thresh;
	cvmx_write_csr(CVMX_IPD_QOSX_RED_MARKS(queue), red_marks.u64);
	red_param.u64 = 0;
	red_param.s.prb_con =
	    (255ul << 24) / (red_marks.s.pass - red_marks.s.drop);
	red_param.s.avg_con = 1;
	red_param.s.new_con = 255;
	red_param.s.use_pcnt = 1;
	cvmx_write_csr(CVMX_IPD_RED_QUEX_PARAM(queue), red_param.u64);
	return 0;
}