vnic_cq_copy.h 1.1 KB

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