Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
0004  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
0005  */
0006 #ifndef _VNIC_CQ_COPY_H_
0007 #define _VNIC_CQ_COPY_H_
0008 
0009 #include "fcpio.h"
0010 
0011 static inline unsigned int vnic_cq_copy_service(
0012     struct vnic_cq *cq,
0013     int (*q_service)(struct vnic_dev *vdev,
0014              unsigned int index,
0015              struct fcpio_fw_req *desc),
0016     unsigned int work_to_do)
0017 
0018 {
0019     struct fcpio_fw_req *desc;
0020     unsigned int work_done = 0;
0021     u8 color;
0022 
0023     desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
0024         cq->ring.desc_size * cq->to_clean);
0025     fcpio_color_dec(desc, &color);
0026 
0027     while (color != cq->last_color) {
0028 
0029         if ((*q_service)(cq->vdev, cq->index, desc))
0030             break;
0031 
0032         cq->to_clean++;
0033         if (cq->to_clean == cq->ring.desc_count) {
0034             cq->to_clean = 0;
0035             cq->last_color = cq->last_color ? 0 : 1;
0036         }
0037 
0038         desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
0039             cq->ring.desc_size * cq->to_clean);
0040         fcpio_color_dec(desc, &color);
0041 
0042         work_done++;
0043         if (work_done >= work_to_do)
0044             break;
0045     }
0046 
0047     return work_done;
0048 }
0049 
0050 #endif /* _VNIC_CQ_COPY_H_ */