0001
0002
0003
0004 #ifndef _VNIC_CQ_FW_H_
0005 #define _VNIC_CQ_FW_H_
0006
0007 #include "snic_fwint.h"
0008
0009 static inline unsigned int
0010 vnic_cq_fw_service(struct vnic_cq *cq,
0011 int (*q_service)(struct vnic_dev *vdev,
0012 unsigned int index,
0013 struct snic_fw_req *desc),
0014 unsigned int work_to_do)
0015
0016 {
0017 struct snic_fw_req *desc;
0018 unsigned int work_done = 0;
0019 u8 color;
0020
0021 desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
0022 cq->ring.desc_size * cq->to_clean);
0023 snic_color_dec(desc, &color);
0024
0025 while (color != cq->last_color) {
0026
0027 if ((*q_service)(cq->vdev, cq->index, desc))
0028 break;
0029
0030 cq->to_clean++;
0031 if (cq->to_clean == cq->ring.desc_count) {
0032 cq->to_clean = 0;
0033 cq->last_color = cq->last_color ? 0 : 1;
0034 }
0035
0036 desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
0037 cq->ring.desc_size * cq->to_clean);
0038 snic_color_dec(desc, &color);
0039
0040 work_done++;
0041 if (work_done >= work_to_do)
0042 break;
0043 }
0044
0045 return work_done;
0046 }
0047
0048 #endif