Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (C) 2007 Krzysztof Halasa <khc@pm.waw.pl>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 */
8
9#ifndef IXP4XX_QMGR_H
10#define IXP4XX_QMGR_H
11
12#include <linux/io.h>
13#include <linux/kernel.h>
14
15#define DEBUG_QMGR 0
16
17#define HALF_QUEUES 32
18#define QUEUES 64
19#define MAX_QUEUE_LENGTH 4 /* in dwords */
20
21#define QUEUE_STAT1_EMPTY 1 /* queue status bits */
22#define QUEUE_STAT1_NEARLY_EMPTY 2
23#define QUEUE_STAT1_NEARLY_FULL 4
24#define QUEUE_STAT1_FULL 8
25#define QUEUE_STAT2_UNDERFLOW 1
26#define QUEUE_STAT2_OVERFLOW 2
27
28#define QUEUE_WATERMARK_0_ENTRIES 0
29#define QUEUE_WATERMARK_1_ENTRY 1
30#define QUEUE_WATERMARK_2_ENTRIES 2
31#define QUEUE_WATERMARK_4_ENTRIES 3
32#define QUEUE_WATERMARK_8_ENTRIES 4
33#define QUEUE_WATERMARK_16_ENTRIES 5
34#define QUEUE_WATERMARK_32_ENTRIES 6
35#define QUEUE_WATERMARK_64_ENTRIES 7
36
37/* queue interrupt request conditions */
38#define QUEUE_IRQ_SRC_EMPTY 0
39#define QUEUE_IRQ_SRC_NEARLY_EMPTY 1
40#define QUEUE_IRQ_SRC_NEARLY_FULL 2
41#define QUEUE_IRQ_SRC_FULL 3
42#define QUEUE_IRQ_SRC_NOT_EMPTY 4
43#define QUEUE_IRQ_SRC_NOT_NEARLY_EMPTY 5
44#define QUEUE_IRQ_SRC_NOT_NEARLY_FULL 6
45#define QUEUE_IRQ_SRC_NOT_FULL 7
46
47struct qmgr_regs {
48 u32 acc[QUEUES][MAX_QUEUE_LENGTH]; /* 0x000 - 0x3FF */
49 u32 stat1[4]; /* 0x400 - 0x40F */
50 u32 stat2[2]; /* 0x410 - 0x417 */
51 u32 statne_h; /* 0x418 - queue nearly empty */
52 u32 statf_h; /* 0x41C - queue full */
53 u32 irqsrc[4]; /* 0x420 - 0x42F IRC source */
54 u32 irqen[2]; /* 0x430 - 0x437 IRQ enabled */
55 u32 irqstat[2]; /* 0x438 - 0x43F - IRQ access only */
56 u32 reserved[1776];
57 u32 sram[2048]; /* 0x2000 - 0x3FFF - config and buffer */
58};
59
60void qmgr_put_entry(unsigned int queue, u32 val);
61u32 qmgr_get_entry(unsigned int queue);
62int qmgr_stat_empty(unsigned int queue);
63int qmgr_stat_below_low_watermark(unsigned int queue);
64int qmgr_stat_full(unsigned int queue);
65int qmgr_stat_overflow(unsigned int queue);
66void qmgr_release_queue(unsigned int queue);
67void qmgr_set_irq(unsigned int queue, int src,
68 void (*handler)(void *pdev), void *pdev);
69void qmgr_enable_irq(unsigned int queue);
70void qmgr_disable_irq(unsigned int queue);
71
72/* request_ and release_queue() must be called from non-IRQ context */
73
74#if DEBUG_QMGR
75extern char qmgr_queue_descs[QUEUES][32];
76
77int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
78 unsigned int nearly_empty_watermark,
79 unsigned int nearly_full_watermark,
80 const char *desc_format, const char* name);
81#else
82int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
83 unsigned int nearly_empty_watermark,
84 unsigned int nearly_full_watermark);
85#define qmgr_request_queue(queue, len, nearly_empty_watermark, \
86 nearly_full_watermark, desc_format, name) \
87 __qmgr_request_queue(queue, len, nearly_empty_watermark, \
88 nearly_full_watermark)
89#endif
90
91#endif