Deleted Added
full compact
cxgb_listen.c (174708) cxgb_listen.c (176472)
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/ulp/tom/cxgb_listen.c 174708 2007-12-17 08:17:51Z kmacy $");
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/ulp/tom/cxgb_listen.c 176472 2008-02-23 01:06:17Z kmacy $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/fcntl.h>
36#include <sys/limits.h>
37#include <sys/lock.h>
38#include <sys/mbuf.h>
39#include <sys/mutex.h>

--- 135 unchanged lines hidden (view full) ---

175 mtx_lock(&d->listen_lock);
176 p->next = d->listen_hash_tab[bucket];
177 d->listen_hash_tab[bucket] = p;
178 mtx_unlock(&d->listen_lock);
179 }
180 return p;
181}
182
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/fcntl.h>
36#include <sys/limits.h>
37#include <sys/lock.h>
38#include <sys/mbuf.h>
39#include <sys/mutex.h>

--- 135 unchanged lines hidden (view full) ---

175 mtx_lock(&d->listen_lock);
176 p->next = d->listen_hash_tab[bucket];
177 d->listen_hash_tab[bucket] = p;
178 mtx_unlock(&d->listen_lock);
179 }
180 return p;
181}
182
183#if 0
184/*
185 * Given a pointer to a listening socket return its server TID by consulting
186 * the socket->stid map. Returns -1 if the socket is not in the map.
187 */
188static int
189listen_hash_find(struct tom_data *d, struct socket *so)
190{
191 int stid = -1, bucket = listen_hashfn(so);
192 struct listen_info *p;
193
183/*
184 * Given a pointer to a listening socket return its server TID by consulting
185 * the socket->stid map. Returns -1 if the socket is not in the map.
186 */
187static int
188listen_hash_find(struct tom_data *d, struct socket *so)
189{
190 int stid = -1, bucket = listen_hashfn(so);
191 struct listen_info *p;
192
194 spin_lock(&d->listen_lock);
193 mtx_lock(&d->listen_lock);
195 for (p = d->listen_hash_tab[bucket]; p; p = p->next)
194 for (p = d->listen_hash_tab[bucket]; p; p = p->next)
196 if (p->sk == sk) {
195 if (p->so == so) {
197 stid = p->stid;
198 break;
199 }
196 stid = p->stid;
197 break;
198 }
200 spin_unlock(&d->listen_lock);
199 mtx_unlock(&d->listen_lock);
201 return stid;
202}
200 return stid;
201}
203#endif
204
205/*
206 * Delete the listen_info structure for a listening socket. Returns the server
207 * TID for the socket if it is present in the socket->stid map, or -1.
208 */
209static int
210listen_hash_del(struct tom_data *d, struct socket *so)
211{

--- 27 unchanged lines hidden (view full) ---

239 struct cpl_pass_open_req *req;
240 struct tom_data *d = TOM_DATA(dev);
241 struct inpcb *inp = sotoinpcb(so);
242 struct listen_ctx *ctx;
243
244 if (!TOM_TUNABLE(dev, activated))
245 return;
246
202
203/*
204 * Delete the listen_info structure for a listening socket. Returns the server
205 * TID for the socket if it is present in the socket->stid map, or -1.
206 */
207static int
208listen_hash_del(struct tom_data *d, struct socket *so)
209{

--- 27 unchanged lines hidden (view full) ---

237 struct cpl_pass_open_req *req;
238 struct tom_data *d = TOM_DATA(dev);
239 struct inpcb *inp = sotoinpcb(so);
240 struct listen_ctx *ctx;
241
242 if (!TOM_TUNABLE(dev, activated))
243 return;
244
247 printf("start listen\n");
245 if (listen_hash_find(d, so) != -1)
246 return;
248
247
249 ctx = malloc(sizeof(*ctx), M_CXGB, M_NOWAIT);
248 CTR1(KTR_TOM, "start listen on port %u", ntohs(inp->inp_lport));
249 ctx = malloc(sizeof(*ctx), M_CXGB, M_NOWAIT|M_ZERO);
250
251 if (!ctx)
252 return;
253
254 ctx->tom_data = d;
255 ctx->lso = so;
250
251 if (!ctx)
252 return;
253
254 ctx->tom_data = d;
255 ctx->lso = so;
256 ctx->ulp_mode = 0; /* DDP if the default */
256 ctx->ulp_mode = TOM_TUNABLE(dev, ddp) && !(so->so_options & SO_NO_DDP) ? ULP_MODE_TCPDDP : 0;
257 LIST_INIT(&ctx->synq_head);
258
259 stid = cxgb_alloc_stid(d->cdev, d->client, ctx);
260 if (stid < 0)
261 goto free_ctx;
262
257 LIST_INIT(&ctx->synq_head);
258
259 stid = cxgb_alloc_stid(d->cdev, d->client, ctx);
260 if (stid < 0)
261 goto free_ctx;
262
263#ifdef notyet
264 /*
265 * XXX need to mark inpcb as referenced
266 */
267 sock_hold(sk);
268#endif
269 m = m_gethdr(M_NOWAIT, MT_DATA);
270 if (m == NULL)
271 goto free_stid;
272 m->m_pkthdr.len = m->m_len = sizeof(*req);
273
274 if (!listen_hash_add(d, so, stid))
275 goto free_all;
276

--- 69 unchanged lines hidden ---
263 m = m_gethdr(M_NOWAIT, MT_DATA);
264 if (m == NULL)
265 goto free_stid;
266 m->m_pkthdr.len = m->m_len = sizeof(*req);
267
268 if (!listen_hash_add(d, so, stid))
269 goto free_all;
270

--- 69 unchanged lines hidden ---