~ubuntu-branches/ubuntu/wily/linux-ti-omap4/wily

« back to all changes in this revision

Viewing changes to ubuntu/alx/alx.h

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Ubuntu: 3.5.0-25.38
  • Date: 2013-02-20 22:03:31 UTC
  • mfrom: (74.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20130220220331-0ea4l33x3cr61nch
Tags: 3.5.0-220.28
* Release Tracking Bug
  - LP: #1130311

[ Paolo Pisati ]

* rebased on Ubuntu-3.5.0-25.38

[ Ubuntu: 3.5.0-25.38 ]

* Release Tracking Bug
  - LP: #1129472
* ptrace: introduce signal_wake_up_state() and ptrace_signal_wake_up()
  - LP: #1119885, #1129192
  - CVE-2013-0871
* ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL
  - LP: #1119885, #1129192
  - CVE-2013-0871
* wake_up_process() should be never used to wakeup a TASK_STOPPED/TRACED
  task
  - LP: #1119885, #1129192
  - CVE-2013-0871

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2012 Qualcomm Atheros, Inc.
 
3
 *
 
4
 * Permission to use, copy, modify, and/or distribute this software for any
 
5
 * purpose with or without fee is hereby granted, provided that the above
 
6
 * copyright notice and this permission notice appear in all copies.
 
7
 *
 
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
15
 */
 
16
 
 
17
#ifndef _ALX_H_
 
18
#define _ALX_H_
 
19
 
 
20
#define ALX_WATCHDOG_TIME   (5 * HZ)
 
21
 
 
22
/* alx_ring_header is a single, contiguous block of memory space
 
23
 * used by the three descriptor rings (tpd, rfd, rrd)
 
24
 */
 
25
struct alx_ring_header {
 
26
        /* virt addr */
 
27
        void        *desc;
 
28
        /* phy addr */
 
29
        dma_addr_t   dma;
 
30
        u32          size;
 
31
};
 
32
 
 
33
/* alx_buffer wraps around a pointer to a socket buffer
 
34
 * so a DMA physical address can be stored along with the skb
 
35
 */
 
36
struct alx_buffer {
 
37
        struct sk_buff *skb;
 
38
        /* DMA address */
 
39
        DEFINE_DMA_UNMAP_ADDR(dma);
 
40
        /* buffer size */
 
41
        DEFINE_DMA_UNMAP_LEN(size);
 
42
        /* information of this buffer */
 
43
        u16             flags;
 
44
};
 
45
#define ALX_BUF_TX_FIRSTFRAG    0x1
 
46
 
 
47
/* rx queue */
 
48
struct alx_rx_queue {
 
49
        struct net_device *netdev;
 
50
        /* device pointer for dma operation */
 
51
        struct device *dev;
 
52
        /* rrd ring virtual addr */
 
53
        struct rrd_desc *rrd_hdr;
 
54
        /* rrd ring physical addr */
 
55
        dma_addr_t rrd_dma;
 
56
        /* rfd ring virtual addr */
 
57
        struct rfd_desc *rfd_hdr;
 
58
        /* rfd ring physical addr */
 
59
        dma_addr_t rfd_dma;
 
60
        /* info for rx-skbs */
 
61
        struct alx_buffer *bf_info;
 
62
 
 
63
        /* number of ring elements */
 
64
        u16 count;
 
65
        /* rfd producer index */
 
66
        u16 pidx;
 
67
        /* rfd consumer index */
 
68
        u16 cidx;
 
69
        u16 rrd_cidx;
 
70
        /* register saving producer index */
 
71
        u16 p_reg;
 
72
        /* register saving consumer index */
 
73
        u16 c_reg;
 
74
        /* queue index */
 
75
        u16 qidx;
 
76
        unsigned long flag;
 
77
 
 
78
        struct sk_buff_head list;
 
79
};
 
80
#define ALX_RQ_USING            1
 
81
#define ALX_RX_ALLOC_THRESH     32
 
82
 
 
83
/* tx queue */
 
84
struct alx_tx_queue {
 
85
        struct net_device *netdev;
 
86
        /* device pointer for dma operation */
 
87
        struct device *dev;
 
88
        /* tpd ring virtual addr */
 
89
        struct tpd_desc *tpd_hdr;
 
90
        dma_addr_t tpd_dma;
 
91
        /* info for tx-skbs pending on HW */
 
92
        struct alx_buffer *bf_info;
 
93
        /* number of ring elements  */
 
94
        u16 count;
 
95
        /* producer index */
 
96
        u16 pidx;
 
97
        /* consumer index */
 
98
        atomic_t cidx;
 
99
        /* register saving producer index */
 
100
        u16 p_reg;
 
101
        /* register saving consumer index */
 
102
        u16 c_reg;
 
103
        /* queue index */
 
104
        u16 qidx;
 
105
};
 
106
 
 
107
#define ALX_TX_WAKEUP_THRESH(_tq) ((_tq)->count / 4)
 
108
#define ALX_DEFAULT_TX_WORK             128
 
109
 
 
110
struct alx_napi {
 
111
        struct napi_struct      napi;
 
112
        struct alx_adapter      *adpt;
 
113
        struct alx_rx_queue     *rxq;
 
114
        struct alx_tx_queue     *txq;
 
115
        int                     vec_idx;
 
116
        u32                     vec_mask;
 
117
        char                    irq_lbl[IFNAMSIZ];
 
118
};
 
119
 
 
120
enum ALX_FLAGS {
 
121
        ALX_FLAG_USING_MSIX = 0,
 
122
        ALX_FLAG_USING_MSI,
 
123
        ALX_FLAG_RESETING,
 
124
        ALX_FLAG_TESTING,
 
125
        ALX_FLAG_HALT,
 
126
        ALX_FLAG_FPGA,
 
127
        ALX_FLAG_TASK_PENDING,
 
128
        ALX_FLAG_TASK_CHK_LINK,
 
129
        ALX_FLAG_TASK_RESET,
 
130
        ALX_FLAG_TASK_UPDATE_SMB,
 
131
 
 
132
        ALX_FLAG_NUMBER_OF_FLAGS,
 
133
};
 
134
 
 
135
 
 
136
struct alx_hw;
 
137
/*
 
138
 *board specific private data structure
 
139
 */
 
140
struct alx_adapter {
 
141
        struct net_device       *netdev;
 
142
        struct pci_dev          *pdev;
 
143
 
 
144
        struct alx_hw           hw;
 
145
 
 
146
        u16                     bd_number;
 
147
 
 
148
        /* totally msix vectors */
 
149
        int                     nr_vec;
 
150
        struct msix_entry       *msix_ent;
 
151
 
 
152
        /* all descriptor memory */
 
153
        struct alx_ring_header  ring_header;
 
154
        int                     tx_ringsz;
 
155
        int                     rx_ringsz;
 
156
        int                     rxbuf_size;
 
157
 
 
158
        struct alx_napi         *qnapi[8];
 
159
        /* number of napi for TX-Q */
 
160
        int                     nr_txq;
 
161
        /* number of napi for RX-Q */
 
162
        int                     nr_rxq;
 
163
        /* number independent hw RX-Q */
 
164
        int                     nr_hwrxq;
 
165
        /* total napi for TX-Q/RX-Q */
 
166
        int                     nr_napi;
 
167
 
 
168
        /* lock for updating stats */
 
169
        spinlock_t              smb_lock;
 
170
 
 
171
        struct work_struct      task;
 
172
        struct net_device_stats net_stats;
 
173
        atomic_t                irq_sem;
 
174
        u16                     msg_enable;
 
175
 
 
176
        unsigned long           flags;
 
177
 
 
178
        /* ethtool private flags */
 
179
        u32                     eth_pflags;
 
180
        int                     eth_diag_vect;
 
181
        int                     eth_diag_cnt;
 
182
};
 
183
 
 
184
 
 
185
#define ALX_FLAG(_adpt, _FLAG) (\
 
186
        test_bit(ALX_FLAG_##_FLAG, &(_adpt)->flags))
 
187
#define ALX_FLAG_SET(_adpt, _FLAG) (\
 
188
        set_bit(ALX_FLAG_##_FLAG, &(_adpt)->flags))
 
189
#define ALX_FLAG_CLEAR(_adpt, _FLAG) (\
 
190
        clear_bit(ALX_FLAG_##_FLAG, &(_adpt)->flags))
 
191
 
 
192
static inline struct alx_rx_queue *alx_hw_rxq(struct alx_rx_queue *rxq)
 
193
{
 
194
        struct alx_adapter *adpt = netdev_priv(rxq->netdev);
 
195
 
 
196
        return ALX_CAP(&adpt->hw, MRQ) ? rxq : adpt->qnapi[0]->rxq;
 
197
}
 
198
 
 
199
/* needed by alx_ethtool.c */
 
200
extern void alx_configure(struct alx_adapter *adpt);
 
201
extern void alx_free_all_ring_resources(struct alx_adapter *adpt);
 
202
extern int alx_setup_all_ring_resources(struct alx_adapter *adpt);
 
203
extern void alx_init_def_rss_idt(struct alx_adapter *adpt);
 
204
extern int alx_alloc_rxring_buf(struct alx_adapter *adpt,
 
205
                                struct alx_rx_queue *rxq);
 
206
extern void alx_init_intr(struct alx_adapter *adpt);
 
207
extern void alx_disable_advanced_intr(struct alx_adapter *adpt);
 
208
extern void alx_reinit(struct alx_adapter *adpt);
 
209
extern void alx_set_ethtool_ops(struct net_device *dev);
 
210
extern char alx_drv_name[];
 
211
extern char alx_drv_version[];
 
212
 
 
213
#endif