Deleted Added
sdiff udiff text old ( 121687 ) new ( 122112 )
full compact
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 * Transmission.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/hatm/if_hatm_tx.c 121687 2003-10-29 15:15:19Z harti $");
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/kernel.h>

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

73#include <dev/pci/pcireg.h>
74#include <dev/pci/pcivar.h>
75
76#include <dev/utopia/utopia.h>
77#include <dev/hatm/if_hatmconf.h>
78#include <dev/hatm/if_hatmreg.h>
79#include <dev/hatm/if_hatmvar.h>
80
81/*
82 * Allocate a new TPD, zero the TPD part. Cannot return NULL if
83 * flag is 0. The TPD is removed from the free list and its used
84 * bit is set.
85 */
86static struct tpd *
87hatm_alloc_tpd(struct hatm_softc *sc, u_int flags)
88{
89 struct tpd *t;

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

119 * and the mbuf is freed. The TPD is put back onto the free list and
120 * its used bit is cleared.
121 */
122static void
123hatm_free_tpd(struct hatm_softc *sc, struct tpd *tpd)
124{
125 if (tpd->mbuf != NULL) {
126 bus_dmamap_unload(sc->tx_tag, tpd->map);
127 m_freem(tpd->mbuf);
128 tpd->mbuf = NULL;
129 }
130
131 /* insert TPD into free list */
132 SLIST_INSERT_HEAD(&sc->tpd_free, tpd, link);
133 TPD_CLR_USED(sc, tpd->no);
134 sc->tpd_nfree++;

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

339 mtx_lock(&sc->mtx);
340 arg.sc = sc;
341
342 while (1) {
343 IF_DEQUEUE(&ifp->if_snd, m);
344 if (m == NULL)
345 break;
346
347 if (m->m_len < sizeof(*aph))
348 if ((m = m_pullup(m, sizeof(*aph))) == NULL)
349 continue;
350
351 aph = mtod(m, struct atm_pseudohdr *);
352 arg.vci = ATM_PH_VCI(aph);
353 arg.vpi = ATM_PH_VPI(aph);
354 m_adj(m, sizeof(*aph));
355
356 if ((len = m->m_pkthdr.len) == 0) {
357 m_freem(m);
358 continue;
359 }
360
361 if ((arg.vpi & ~HE_VPI_MASK) || (arg.vci & ~HE_VCI_MASK) ||
362 (arg.vci == 0)) {
363 m_freem(m);
364 continue;
365 }
366 cid = HE_CID(arg.vpi, arg.vci);
367 arg.vcc = sc->vccs[cid];
368
369 if (arg.vcc == NULL || !(arg.vcc->vflags & HE_VCC_OPEN)) {
370 m_freem(m);
371 continue;
372 }
373 if (arg.vcc->vflags & HE_VCC_FLOW_CTRL) {
374 m_freem(m);
375 sc->istats.flow_drop++;
376 continue;
377 }
378
379 arg.pti = 0;
380 if (arg.vcc->param.aal == ATMIO_AAL_RAW) {
381 if (len < 52) {
382 /* too short */
383 m_freem(m);
384 continue;
385 }
386
387 /*
388 * Get the header and ignore except
389 * payload type and CLP.
390 */
391 if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL)
392 continue;
393 arg.pti = mtod(m, u_char *)[3] & 0xf;
394 arg.pti = ((arg.pti & 0xe) << 2) | ((arg.pti & 1) << 1);
395 m_adj(m, 4);
396 len -= 4;
397
398 if (len % 48 != 0) {
399 m_adj(m, -((int)(len % 48)));
400 len -= len % 48;

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

407 (arg.vcc->param.flags & ATM_PH_LLCSNAP))
408 BPF_MTAP(ifp, m);
409#endif
410
411 /* Now load a DMA map with the packet. Allocate the first
412 * TPD to get a map. Additional TPDs may be allocated by the
413 * callback. */
414 if ((tpd = hatm_alloc_tpd(sc, M_NOWAIT)) == NULL) {
415 m_freem(m);
416 sc->ifatm.ifnet.if_oerrors++;
417 continue;
418 }
419 tpd->cid = cid;
420 tpd->tpd.addr |= arg.pti;
421 arg.first = tpd;
422 arg.error = 0;
423 arg.mbuf = m;
424
425 error = bus_dmamap_load_mbuf(sc->tx_tag, tpd->map, m,
426 hatm_load_txbuf, &arg, BUS_DMA_NOWAIT);
427
428 if (error == EFBIG) {
429 /* try to defragment the packet */
430 sc->istats.defrag++;
431 m = m_defrag(m, M_DONTWAIT);
432 if (m == NULL) {
433 sc->ifatm.ifnet.if_oerrors++;
434 continue;
435 }
436 arg.mbuf = m;
437 error = bus_dmamap_load_mbuf(sc->tx_tag, tpd->map, m,
438 hatm_load_txbuf, &arg, BUS_DMA_NOWAIT);
439 }
440

--- 345 unchanged lines hidden ---