|
|
1.1 root 1: m88k ethernet buffer notes
2:
3:
4: /*
5: * This is exactly 2k bytes, aligned to a 2k byte boundary. The actual
6: * DMA data is inside of here, aligned for proper enet DMA.
7: *
8: * An enetBuf as associated with a netbuf_t at getbuf time via the
9: * freefunc and freefuncarg mechanism, and at RX DMA enqueue time by
10: * setting dma_id = netbuf.
11: *
12: * We keep separate pools of TX and RX ebetBufs. For now, a fixed number
13: * of TX and RX enetBufs are allocated at init time; no more are
14: * allocated after that.
15: */
16: typedef struct {
17: enetBuf_t *next;
18: id owner;
19: boolean_t Rx;
20: char filler[to align dmaData for DMA];
21: char dmaData[max packet size];
22: char filler[to fill out to 2048 bytes];
23: } enetBuf_t;
24:
25: boot {
26: create a list of empty enetBuf_t's, enqueue on RxBufList and
27: TxBufList;
28: rxDmaQCount = 0;
29: do {
30: get an enetBuf from RxBufList;
31: netbuf = nb_alloc_wrapper(&enetBuf->dmaData,
32: size of DMA Data,
33: &enetBufFree(),
34: &enetBuf);
35: /*
36: * Our record of netbuf is via dma_id!
37: */
38: dma_enqueue(data = &enetBuf.dmaData,
39: dma_id = netbuf,
40: length = sizeof DMA data);
41: rxDmaQCount++;
42: } for each buf in RxBufList;
43: }
44:
45: getbuf {
46: get a free enetBuf from TxBufList;
47: return NULL if list empty;
48: return(nb_alloc_wrapper(&enetBuf->dmaData,
49: size of DMA Data,
50: &enetBufFree(),
51: &enetBuf));
52: }
53:
54: output {
55: dma_enqueue(data = nb_map(netbuf),
56: dma_id = netbuf,
57: length = nb_size(netbuf));
58: }
59:
60: TX DMA complete {
61: do {
62: dma_id = chan_dma_dequeue(COMPLETED);
63: nb_free((netbuf_t)dma_id);
64: } for all frames;
65: }
66:
67: RX DMA complete {
68: do {
69: dma_id = chan_dma_dequeue(COMPLETED);
70: if_handle_input(netif, (netbuf_t)dma_id, NULL);
71: } for all frames;
72: do {
73: get an enetBuf from RxBufList;
74: netbuf = nb_alloc_wrapper(&enetBuf->dmaData,
75: size of DMA Data,
76: &enetBufFree(),
77: &enetBuf);
78: dma_enqueue(data = &enetBuf.dmaData,
79: dma_id = netbuf,
80: length = sizeof DMA data);
81: rxDmaQCount++;
82:
83: } for each buf in RxBufList;
84: }
85:
86: /*
87: * Called out from nb_free(), as freefunc(freefunc_arg).
88: */
89: enetBufFree(enetBuf_t *enetBuf) {
90: enqueue this on TxBufList or RxBufList;
91: }
92:
93: Notes
94: -----
95:
96: * Memory throttle is via getbuf returning NULL. Joel has a limit of 10 RX and
97: 10 TX buffers in the Token Ring driver. Current 68k enet driver has no
98: limit. Brad and Joel say that it should not cause problems for the
99: driver to return NULL on getbuf()...Brad will help track down problems
100: in this area.
101:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.