|
@@ -37,7 +37,7 @@ static int vnic_rq_alloc_bufs(struct vnic_rq *rq)
|
|
|
vdev = rq->vdev;
|
|
|
|
|
|
for (i = 0; i < blks; i++) {
|
|
|
- rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ, GFP_ATOMIC);
|
|
|
+ rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ(count), GFP_ATOMIC);
|
|
|
if (!rq->bufs[i]) {
|
|
|
pr_err("Failed to alloc rq_bufs\n");
|
|
|
return -ENOMEM;
|
|
@@ -46,14 +46,14 @@ static int vnic_rq_alloc_bufs(struct vnic_rq *rq)
|
|
|
|
|
|
for (i = 0; i < blks; i++) {
|
|
|
buf = rq->bufs[i];
|
|
|
- for (j = 0; j < VNIC_RQ_BUF_BLK_ENTRIES; j++) {
|
|
|
- buf->index = i * VNIC_RQ_BUF_BLK_ENTRIES + j;
|
|
|
+ for (j = 0; j < VNIC_RQ_BUF_BLK_ENTRIES(count); j++) {
|
|
|
+ buf->index = i * VNIC_RQ_BUF_BLK_ENTRIES(count) + j;
|
|
|
buf->desc = (u8 *)rq->ring.descs +
|
|
|
rq->ring.desc_size * buf->index;
|
|
|
if (buf->index + 1 == count) {
|
|
|
buf->next = rq->bufs[0];
|
|
|
break;
|
|
|
- } else if (j + 1 == VNIC_RQ_BUF_BLK_ENTRIES) {
|
|
|
+ } else if (j + 1 == VNIC_RQ_BUF_BLK_ENTRIES(count)) {
|
|
|
buf->next = rq->bufs[i + 1];
|
|
|
} else {
|
|
|
buf->next = buf + 1;
|
|
@@ -119,10 +119,11 @@ void vnic_rq_init_start(struct vnic_rq *rq, unsigned int cq_index,
|
|
|
unsigned int error_interrupt_offset)
|
|
|
{
|
|
|
u64 paddr;
|
|
|
+ unsigned int count = rq->ring.desc_count;
|
|
|
|
|
|
paddr = (u64)rq->ring.base_addr | VNIC_PADDR_TARGET;
|
|
|
writeq(paddr, &rq->ctrl->ring_base);
|
|
|
- iowrite32(rq->ring.desc_count, &rq->ctrl->ring_size);
|
|
|
+ iowrite32(count, &rq->ctrl->ring_size);
|
|
|
iowrite32(cq_index, &rq->ctrl->cq_index);
|
|
|
iowrite32(error_interrupt_enable, &rq->ctrl->error_interrupt_enable);
|
|
|
iowrite32(error_interrupt_offset, &rq->ctrl->error_interrupt_offset);
|
|
@@ -132,8 +133,8 @@ void vnic_rq_init_start(struct vnic_rq *rq, unsigned int cq_index,
|
|
|
iowrite32(posted_index, &rq->ctrl->posted_index);
|
|
|
|
|
|
rq->to_use = rq->to_clean =
|
|
|
- &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES]
|
|
|
- [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES];
|
|
|
+ &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES(count)]
|
|
|
+ [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES(count)];
|
|
|
}
|
|
|
|
|
|
void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
|
|
@@ -184,6 +185,7 @@ void vnic_rq_clean(struct vnic_rq *rq,
|
|
|
{
|
|
|
struct vnic_rq_buf *buf;
|
|
|
u32 fetch_index;
|
|
|
+ unsigned int count = rq->ring.desc_count;
|
|
|
|
|
|
BUG_ON(ioread32(&rq->ctrl->enable));
|
|
|
|
|
@@ -200,8 +202,8 @@ void vnic_rq_clean(struct vnic_rq *rq,
|
|
|
/* Use current fetch_index as the ring starting point */
|
|
|
fetch_index = ioread32(&rq->ctrl->fetch_index);
|
|
|
rq->to_use = rq->to_clean =
|
|
|
- &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES]
|
|
|
- [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES];
|
|
|
+ &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES(count)]
|
|
|
+ [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES(count)];
|
|
|
iowrite32(fetch_index, &rq->ctrl->posted_index);
|
|
|
|
|
|
vnic_dev_clear_desc_ring(&rq->ring);
|