1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _CXGB3_OFFLOAD_H
33#define _CXGB3_OFFLOAD_H
34
35#include <linux/list.h>
36#include <linux/skbuff.h>
37
38#include "l2t.h"
39
40#include "t3cdev.h"
41#include "t3_cpl.h"
42
43struct adapter;
44
45void cxgb3_offload_init(void);
46
47void cxgb3_adapter_ofld(struct adapter *adapter);
48void cxgb3_adapter_unofld(struct adapter *adapter);
49int cxgb3_offload_activate(struct adapter *adapter);
50void cxgb3_offload_deactivate(struct adapter *adapter);
51
52void cxgb3_set_dummy_ops(struct t3cdev *dev);
53
54struct t3cdev *dev2t3cdev(struct net_device *dev);
55
56
57
58
59
60
61
62
63void cxgb3_register_client(struct cxgb3_client *client);
64void cxgb3_unregister_client(struct cxgb3_client *client);
65void cxgb3_add_clients(struct t3cdev *tdev);
66void cxgb3_remove_clients(struct t3cdev *tdev);
67void cxgb3_event_notify(struct t3cdev *tdev, u32 event, u32 port);
68
69typedef int (*cxgb3_cpl_handler_func)(struct t3cdev *dev,
70 struct sk_buff *skb, void *ctx);
71
72enum {
73 OFFLOAD_STATUS_UP,
74 OFFLOAD_STATUS_DOWN,
75 OFFLOAD_PORT_DOWN,
76 OFFLOAD_PORT_UP
77};
78
79struct cxgb3_client {
80 char *name;
81 void (*add) (struct t3cdev *);
82 void (*remove) (struct t3cdev *);
83 cxgb3_cpl_handler_func *handlers;
84 int (*redirect)(void *ctx, struct dst_entry *old,
85 struct dst_entry *new, struct l2t_entry *l2t);
86 struct list_head client_list;
87 void (*event_handler)(struct t3cdev *tdev, u32 event, u32 port);
88};
89
90
91
92
93int cxgb3_alloc_atid(struct t3cdev *dev, struct cxgb3_client *client,
94 void *ctx);
95int cxgb3_alloc_stid(struct t3cdev *dev, struct cxgb3_client *client,
96 void *ctx);
97void *cxgb3_free_atid(struct t3cdev *dev, int atid);
98void cxgb3_free_stid(struct t3cdev *dev, int stid);
99void cxgb3_insert_tid(struct t3cdev *dev, struct cxgb3_client *client,
100 void *ctx, unsigned int tid);
101void cxgb3_queue_tid_release(struct t3cdev *dev, unsigned int tid);
102void cxgb3_remove_tid(struct t3cdev *dev, void *ctx, unsigned int tid);
103
104struct t3c_tid_entry {
105 struct cxgb3_client *client;
106 void *ctx;
107};
108
109
110enum {
111 CPL_PRIORITY_DATA = 0,
112 CPL_PRIORITY_SETUP = 1,
113 CPL_PRIORITY_TEARDOWN = 0,
114 CPL_PRIORITY_LISTEN = 1,
115 CPL_PRIORITY_ACK = 1,
116 CPL_PRIORITY_CONTROL = 1
117};
118
119
120enum {
121 CPL_RET_BUF_DONE = 1,
122 CPL_RET_BAD_MSG = 2,
123 CPL_RET_UNKNOWN_TID = 4
124};
125
126typedef int (*cpl_handler_func)(struct t3cdev *dev, struct sk_buff *skb);
127
128
129
130
131
132static inline void *cplhdr(struct sk_buff *skb)
133{
134 return skb->data;
135}
136
137void t3_register_cpl_handler(unsigned int opcode, cpl_handler_func h);
138
139union listen_entry {
140 struct t3c_tid_entry t3c_tid;
141 union listen_entry *next;
142};
143
144union active_open_entry {
145 struct t3c_tid_entry t3c_tid;
146 union active_open_entry *next;
147};
148
149
150
151
152
153
154struct tid_info {
155 struct t3c_tid_entry *tid_tab;
156 unsigned int ntids;
157 atomic_t tids_in_use;
158
159 union listen_entry *stid_tab;
160 unsigned int nstids;
161 unsigned int stid_base;
162
163 union active_open_entry *atid_tab;
164 unsigned int natids;
165 unsigned int atid_base;
166
167
168
169
170
171
172
173
174
175 spinlock_t atid_lock ____cacheline_aligned_in_smp;
176 union active_open_entry *afree;
177 unsigned int atids_in_use;
178
179 spinlock_t stid_lock ____cacheline_aligned;
180 union listen_entry *sfree;
181 unsigned int stids_in_use;
182};
183
184struct t3c_data {
185 struct list_head list_node;
186 struct t3cdev *dev;
187 unsigned int tx_max_chunk;
188 unsigned int max_wrs;
189 unsigned int nmtus;
190 const unsigned short *mtus;
191 struct tid_info tid_maps;
192
193 struct t3c_tid_entry *tid_release_list;
194 spinlock_t tid_release_lock;
195 struct work_struct tid_release_task;
196
197 struct sk_buff *nofail_skb;
198 unsigned int release_list_incomplete;
199};
200
201
202
203
204#define T3C_DATA(dev) (*(struct t3c_data **)&(dev)->l4opt)
205
206#endif
207