Deleted Added
full compact
if_hatm_ioctl.c (139749) if_hatm_ioctl.c (147256)
1/*-
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * Author: Hartmut Brandt <harti@freebsd.org>
28 *
29 * ForeHE driver.
30 *
31 * Ioctl handler.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * Author: Hartmut Brandt <harti@freebsd.org>
28 *
29 * ForeHE driver.
30 *
31 * Ioctl handler.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/hatm/if_hatm_ioctl.c 139749 2005-01-06 01:43:34Z imp $");
35__FBSDID("$FreeBSD: head/sys/dev/hatm/if_hatm_ioctl.c 147256 2005-06-10 16:49:24Z brooks $");
36
37#include "opt_inet.h"
38#include "opt_natm.h"
39
40#include <sys/types.h>
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/malloc.h>

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

111 (arg->param.flags & ATMIO_FLAG_NORX))
112 return (EINVAL);
113
114 vcc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO);
115 if (vcc == NULL)
116 return (ENOMEM);
117
118 mtx_lock(&sc->mtx);
36
37#include "opt_inet.h"
38#include "opt_natm.h"
39
40#include <sys/types.h>
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/malloc.h>

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

111 (arg->param.flags & ATMIO_FLAG_NORX))
112 return (EINVAL);
113
114 vcc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO);
115 if (vcc == NULL)
116 return (ENOMEM);
117
118 mtx_lock(&sc->mtx);
119 if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
119 if (!(sc->ifp->if_flags & IFF_RUNNING)) {
120 error = EIO;
121 goto done;
122 }
123 if (sc->vccs[cid] != NULL) {
124 error = EBUSY;
125 goto done;
126 }
127 vcc->param = arg->param;

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

183 hatm_rx_vcc_open(sc, cid);
184
185 if (reopen)
186 return;
187
188 /* inform management about non-NG and NG-PVCs */
189 if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
190 (vcc->param.flags & ATMIO_FLAG_PVC))
120 error = EIO;
121 goto done;
122 }
123 if (sc->vccs[cid] != NULL) {
124 error = EBUSY;
125 goto done;
126 }
127 vcc->param = arg->param;

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

183 hatm_rx_vcc_open(sc, cid);
184
185 if (reopen)
186 return;
187
188 /* inform management about non-NG and NG-PVCs */
189 if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
190 (vcc->param.flags & ATMIO_FLAG_PVC))
191 ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->param.vpi,
191 ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->param.vpi,
192 vcc->param.vci, 1);
193}
194
195/*
196 * VCC has been finally closed.
197 */
198void
199hatm_vcc_closed(struct hatm_softc *sc, u_int cid)
200{
201 struct hevcc *vcc = sc->vccs[cid];
202
203 /* inform management about non-NG and NG-PVCs */
204 if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
205 (vcc->param.flags & ATMIO_FLAG_PVC))
192 vcc->param.vci, 1);
193}
194
195/*
196 * VCC has been finally closed.
197 */
198void
199hatm_vcc_closed(struct hatm_softc *sc, u_int cid)
200{
201 struct hevcc *vcc = sc->vccs[cid];
202
203 /* inform management about non-NG and NG-PVCs */
204 if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
205 (vcc->param.flags & ATMIO_FLAG_PVC))
206 ATMEV_SEND_VCC_CHANGED(&sc->ifatm, HE_VPI(cid), HE_VCI(cid), 0);
206 ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), HE_VPI(cid), HE_VCI(cid), 0);
207
208 sc->open_vccs--;
209 uma_zfree(sc->vcc_zone, vcc);
210 sc->vccs[cid] = NULL;
211}
212
213/*
214 * Try to close the given VCC

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

225 if((arg->vpi & ~HE_VPI_MASK) ||
226 (arg->vci & ~HE_VCI_MASK) ||
227 (arg->vci == 0))
228 return (EINVAL);
229 cid = HE_CID(arg->vpi, arg->vci);
230
231 mtx_lock(&sc->mtx);
232 vcc = sc->vccs[cid];
207
208 sc->open_vccs--;
209 uma_zfree(sc->vcc_zone, vcc);
210 sc->vccs[cid] = NULL;
211}
212
213/*
214 * Try to close the given VCC

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

225 if((arg->vpi & ~HE_VPI_MASK) ||
226 (arg->vci & ~HE_VCI_MASK) ||
227 (arg->vci == 0))
228 return (EINVAL);
229 cid = HE_CID(arg->vpi, arg->vci);
230
231 mtx_lock(&sc->mtx);
232 vcc = sc->vccs[cid];
233 if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
233 if (!(sc->ifp->if_flags & IFF_RUNNING)) {
234 error = EIO;
235 goto done;
236 }
237
238 if (vcc == NULL || !(vcc->vflags & HE_VCC_OPEN)) {
239 error = ENOENT;
240 goto done;
241 }
242
243 if (vcc->vflags & HE_VCC_TX_OPEN)
244 hatm_tx_vcc_close(sc, cid);
245 if (vcc->vflags & HE_VCC_RX_OPEN)
246 hatm_rx_vcc_close(sc, cid);
247
248 if (vcc->param.flags & ATMIO_FLAG_ASYNC)
249 goto done;
250
234 error = EIO;
235 goto done;
236 }
237
238 if (vcc == NULL || !(vcc->vflags & HE_VCC_OPEN)) {
239 error = ENOENT;
240 goto done;
241 }
242
243 if (vcc->vflags & HE_VCC_TX_OPEN)
244 hatm_tx_vcc_close(sc, cid);
245 if (vcc->vflags & HE_VCC_RX_OPEN)
246 hatm_rx_vcc_close(sc, cid);
247
248 if (vcc->param.flags & ATMIO_FLAG_ASYNC)
249 goto done;
250
251 while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
251 while ((sc->ifp->if_flags & IFF_RUNNING) &&
252 (vcc->vflags & (HE_VCC_TX_CLOSING | HE_VCC_RX_CLOSING)))
253 cv_wait(&sc->vcc_cv, &sc->mtx);
254
252 (vcc->vflags & (HE_VCC_TX_CLOSING | HE_VCC_RX_CLOSING)))
253 cv_wait(&sc->vcc_cv, &sc->mtx);
254
255 if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
255 if (!(sc->ifp->if_flags & IFF_RUNNING)) {
256 error = EIO;
257 goto done;
258 }
259
260 if (!(vcc->vflags & ATMIO_FLAG_NOTX))
261 hatm_tx_vcc_closed(sc, cid);
262
263 hatm_vcc_closed(sc, cid);

--- 121 unchanged lines hidden ---
256 error = EIO;
257 goto done;
258 }
259
260 if (!(vcc->vflags & ATMIO_FLAG_NOTX))
261 hatm_tx_vcc_closed(sc, cid);
262
263 hatm_vcc_closed(sc, cid);

--- 121 unchanged lines hidden ---