vnic_cq_fw.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
  3. #ifndef _VNIC_CQ_FW_H_
  4. #define _VNIC_CQ_FW_H_
  5. #include "snic_fwint.h"
  6. static inline unsigned int
  7. vnic_cq_fw_service(struct vnic_cq *cq,
  8. int (*q_service)(struct vnic_dev *vdev,
  9. unsigned int index,
  10. struct snic_fw_req *desc),
  11. unsigned int work_to_do)
  12. {
  13. struct snic_fw_req *desc;
  14. unsigned int work_done = 0;
  15. u8 color;
  16. desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
  17. cq->ring.desc_size * cq->to_clean);
  18. snic_color_dec(desc, &color);
  19. while (color != cq->last_color) {
  20. if ((*q_service)(cq->vdev, cq->index, desc))
  21. break;
  22. cq->to_clean++;
  23. if (cq->to_clean == cq->ring.desc_count) {
  24. cq->to_clean = 0;
  25. cq->last_color = cq->last_color ? 0 : 1;
  26. }
  27. desc = (struct snic_fw_req *)((u8 *)cq->ring.descs +
  28. cq->ring.desc_size * cq->to_clean);
  29. snic_color_dec(desc, &color);
  30. work_done++;
  31. if (work_done >= work_to_do)
  32. break;
  33. }
  34. return work_done;
  35. }
  36. #endif /* _VNIC_CQ_FW_H_ */