209 return (rqbd);
210 } /* oce_rqb_alloc */
211
212 /*
213 * function to free the RQ buffer
214 *
215 * rq - pointer to RQ structure
216 * rqbd - pointer to recieve buffer descriptor
217 *
218 * return none
219 */
220 static inline void
221 oce_rqb_free(struct oce_rq *rq, oce_rq_bdesc_t *rqbd)
222 {
223 uint32_t free_index;
224 mutex_enter(&rq->rc_lock);
225 free_index = rq->rqb_rc_head;
226 rq->rqb_freelist[free_index] = rqbd;
227 rq->rqb_rc_head = GET_Q_NEXT(free_index, 1, rq->cfg.nbufs);
228 mutex_exit(&rq->rc_lock);
229 atomic_add_32(&rq->rqb_free, 1);
230 } /* oce_rqb_free */
231
232
233
234
235 static void oce_rq_post_buffer(struct oce_rq *rq, int nbufs)
236 {
237 pd_rxulp_db_t rxdb_reg;
238 int count;
239 struct oce_dev *dev = rq->parent;
240
241
242 rxdb_reg.dw0 = 0;
243 rxdb_reg.bits.qid = rq->rq_id & DB_RQ_ID_MASK;
244
245 for (count = nbufs/OCE_MAX_RQ_POSTS; count > 0; count--) {
246 rxdb_reg.bits.num_posted = OCE_MAX_RQ_POSTS;
247 OCE_DB_WRITE32(dev, PD_RXULP_DB, rxdb_reg.dw0);
248 rq->buf_avail += OCE_MAX_RQ_POSTS;
249 nbufs -= OCE_MAX_RQ_POSTS;
581 oce_rq_bdesc_t *rqbd;
582 struct oce_rq *rq;
583
584 /* During destroy, arg will be NULL */
585 if (arg == NULL) {
586 return;
587 }
588
589 /* retrieve the pointers from arg */
590 rqbd = (oce_rq_bdesc_t *)(void *)arg;
591 rq = rqbd->rq;
592 rqbd->mp = desballoc((uchar_t *)rqbd->rqb->base,
593 rqbd->rqb->size, 0, &rqbd->fr_rtn);
594
595 if (rqbd->mp) {
596 rqbd->mp->b_rptr =
597 (uchar_t *)rqbd->rqb->base + OCE_RQE_BUF_HEADROOM;
598 }
599
600 oce_rqb_free(rq, rqbd);
601 (void) atomic_add_32(&rq->pending, -1);
602 } /* rx_pool_free */
603
604 /*
605 * function to stop the RX
606 *
607 * rq - pointer to RQ structure
608 *
609 * return none
610 */
611 void
612 oce_clean_rq(struct oce_rq *rq)
613 {
614 uint16_t num_cqe = 0;
615 struct oce_cq *cq;
616 struct oce_dev *dev;
617 struct oce_nic_rx_cqe *cqe;
618 int32_t ti = 0;
619
620 dev = rq->parent;
621 cq = rq->cq;
|
209 return (rqbd);
210 } /* oce_rqb_alloc */
211
212 /*
213 * function to free the RQ buffer
214 *
215 * rq - pointer to RQ structure
216 * rqbd - pointer to recieve buffer descriptor
217 *
218 * return none
219 */
220 static inline void
221 oce_rqb_free(struct oce_rq *rq, oce_rq_bdesc_t *rqbd)
222 {
223 uint32_t free_index;
224 mutex_enter(&rq->rc_lock);
225 free_index = rq->rqb_rc_head;
226 rq->rqb_freelist[free_index] = rqbd;
227 rq->rqb_rc_head = GET_Q_NEXT(free_index, 1, rq->cfg.nbufs);
228 mutex_exit(&rq->rc_lock);
229 atomic_inc_32(&rq->rqb_free);
230 } /* oce_rqb_free */
231
232
233
234
235 static void oce_rq_post_buffer(struct oce_rq *rq, int nbufs)
236 {
237 pd_rxulp_db_t rxdb_reg;
238 int count;
239 struct oce_dev *dev = rq->parent;
240
241
242 rxdb_reg.dw0 = 0;
243 rxdb_reg.bits.qid = rq->rq_id & DB_RQ_ID_MASK;
244
245 for (count = nbufs/OCE_MAX_RQ_POSTS; count > 0; count--) {
246 rxdb_reg.bits.num_posted = OCE_MAX_RQ_POSTS;
247 OCE_DB_WRITE32(dev, PD_RXULP_DB, rxdb_reg.dw0);
248 rq->buf_avail += OCE_MAX_RQ_POSTS;
249 nbufs -= OCE_MAX_RQ_POSTS;
581 oce_rq_bdesc_t *rqbd;
582 struct oce_rq *rq;
583
584 /* During destroy, arg will be NULL */
585 if (arg == NULL) {
586 return;
587 }
588
589 /* retrieve the pointers from arg */
590 rqbd = (oce_rq_bdesc_t *)(void *)arg;
591 rq = rqbd->rq;
592 rqbd->mp = desballoc((uchar_t *)rqbd->rqb->base,
593 rqbd->rqb->size, 0, &rqbd->fr_rtn);
594
595 if (rqbd->mp) {
596 rqbd->mp->b_rptr =
597 (uchar_t *)rqbd->rqb->base + OCE_RQE_BUF_HEADROOM;
598 }
599
600 oce_rqb_free(rq, rqbd);
601 (void) atomic_dec_32(&rq->pending);
602 } /* rx_pool_free */
603
604 /*
605 * function to stop the RX
606 *
607 * rq - pointer to RQ structure
608 *
609 * return none
610 */
611 void
612 oce_clean_rq(struct oce_rq *rq)
613 {
614 uint16_t num_cqe = 0;
615 struct oce_cq *cq;
616 struct oce_dev *dev;
617 struct oce_nic_rx_cqe *cqe;
618 int32_t ti = 0;
619
620 dev = rq->parent;
621 cq = rq->cq;
|