Linux Audio

Check our new training course

Loading...
v3.15
 
 1/*
 2 * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
 3 * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
 4 *
 5 * This program is free software; you may redistribute it and/or modify
 6 * it under the terms of the GNU General Public License as published by
 7 * the Free Software Foundation; version 2 of the License.
 8 *
 9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16 * SOFTWARE.
17 */
18#ifndef _VNIC_CQ_COPY_H_
19#define _VNIC_CQ_COPY_H_
20
21#include "fcpio.h"
22
23static inline unsigned int vnic_cq_copy_service(
24	struct vnic_cq *cq,
25	int (*q_service)(struct vnic_dev *vdev,
26			 unsigned int index,
27			 struct fcpio_fw_req *desc),
28	unsigned int work_to_do)
29
30{
31	struct fcpio_fw_req *desc;
32	unsigned int work_done = 0;
33	u8 color;
34
35	desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
36		cq->ring.desc_size * cq->to_clean);
37	fcpio_color_dec(desc, &color);
38
39	while (color != cq->last_color) {
40
41		if ((*q_service)(cq->vdev, cq->index, desc))
42			break;
43
44		cq->to_clean++;
45		if (cq->to_clean == cq->ring.desc_count) {
46			cq->to_clean = 0;
47			cq->last_color = cq->last_color ? 0 : 1;
48		}
49
50		desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
51			cq->ring.desc_size * cq->to_clean);
52		fcpio_color_dec(desc, &color);
53
54		work_done++;
55		if (work_done >= work_to_do)
56			break;
57	}
58
59	return work_done;
60}
61
62#endif /* _VNIC_CQ_COPY_H_ */
v6.13.7
 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
 9#include "fcpio.h"
10
11static inline unsigned int vnic_cq_copy_service(
12	struct vnic_cq *cq,
13	int (*q_service)(struct vnic_dev *vdev,
14			 unsigned int index,
15			 struct fcpio_fw_req *desc),
16	unsigned int work_to_do)
17
18{
19	struct fcpio_fw_req *desc;
20	unsigned int work_done = 0;
21	u8 color;
22
23	desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
24		cq->ring.desc_size * cq->to_clean);
25	fcpio_color_dec(desc, &color);
26
27	while (color != cq->last_color) {
28
29		if ((*q_service)(cq->vdev, cq->index, desc))
30			break;
31
32		cq->to_clean++;
33		if (cq->to_clean == cq->ring.desc_count) {
34			cq->to_clean = 0;
35			cq->last_color = cq->last_color ? 0 : 1;
36		}
37
38		desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs +
39			cq->ring.desc_size * cq->to_clean);
40		fcpio_color_dec(desc, &color);
41
42		work_done++;
43		if (work_done >= work_to_do)
44			break;
45	}
46
47	return work_done;
48}
49
50#endif /* _VNIC_CQ_COPY_H_ */