Lines Matching defs:buf
232 struct lanai_buffer buf;
236 struct lanai_buffer buf;
323 * Returns buf->start==NULL if no memory
328 static void lanai_buf_allocate(struct lanai_buffer *buf,
345 buf->start = dma_alloc_coherent(&pci->dev,
346 size, &buf->dmaaddr, GFP_KERNEL);
347 if (buf->start != NULL) { /* Success */
349 APRINTK((buf->dmaaddr & ~0xFFFFFF00) == 0,
351 (unsigned long) buf->dmaaddr);
352 buf->ptr = buf->start;
353 buf->end = (u32 *)
354 (&((unsigned char *) buf->start)[size]);
355 memset(buf->start, 0, size);
363 static inline size_t lanai_buf_size(const struct lanai_buffer *buf)
365 return ((unsigned long) buf->end) - ((unsigned long) buf->start);
368 static void lanai_buf_deallocate(struct lanai_buffer *buf,
371 if (buf->start != NULL) {
372 dma_free_coherent(&pci->dev, lanai_buf_size(buf),
373 buf->start, buf->dmaaddr);
374 buf->start = buf->end = buf->ptr = NULL;
379 static int lanai_buf_size_cardorder(const struct lanai_buffer *buf)
381 int order = get_order(lanai_buf_size(buf)) + (PAGE_SHIFT - 10);
697 dma_addr_t dmaaddr = lvcc->rx.buf.dmaaddr;
705 RXADDR1_SET_SIZE(lanai_buf_size_cardorder(&lvcc->rx.buf))|
719 dma_addr_t dmaaddr = lvcc->tx.buf.dmaaddr;
732 TXADDR1_SET_SIZE(lanai_buf_size_cardorder(&lvcc->tx.buf)),
784 (((lanai_buf_size(&lvcc->tx.buf) / 1024) * HZ) >> 7);
1138 r -= ((unsigned long) lvcc->tx.buf.ptr) -
1139 ((unsigned long) lvcc->tx.buf.start);
1142 r += lanai_buf_size(&lvcc->tx.buf);
1163 APRINTK((((unsigned long) lvcc->tx.buf.ptr) & 15) == 0,
1164 "vcc_tx_add_aal5_descriptor: bad ptr=%p\n", lvcc->tx.buf.ptr);
1165 lvcc->tx.buf.ptr += 4; /* Hope the values REALLY don't matter */
1166 pos = ((unsigned char *) lvcc->tx.buf.ptr) -
1167 (unsigned char *) lvcc->tx.buf.start;
1171 lvcc->tx.buf.start, lvcc->tx.buf.ptr, lvcc->tx.buf.end);
1172 pos = (pos + len) & (lanai_buf_size(&lvcc->tx.buf) - 1);
1176 lvcc->tx.buf.start, lvcc->tx.buf.ptr, lvcc->tx.buf.end);
1177 lvcc->tx.buf.ptr[-1] =
1181 if (lvcc->tx.buf.ptr >= lvcc->tx.buf.end)
1182 lvcc->tx.buf.ptr = lvcc->tx.buf.start;
1189 APRINTK((((unsigned long) lvcc->tx.buf.ptr) & 15) == 8,
1190 "vcc_tx_add_aal5_trailer: bad ptr=%p\n", lvcc->tx.buf.ptr);
1191 lvcc->tx.buf.ptr += 2;
1192 lvcc->tx.buf.ptr[-2] = cpu_to_be32((uu << 24) | (cpi << 16) | len);
1193 if (lvcc->tx.buf.ptr >= lvcc->tx.buf.end)
1194 lvcc->tx.buf.ptr = lvcc->tx.buf.start;
1202 e = ((unsigned char *) lvcc->tx.buf.ptr) + n;
1203 m = e - (unsigned char *) lvcc->tx.buf.end;
1206 memcpy(lvcc->tx.buf.ptr, src, n - m);
1208 memcpy(lvcc->tx.buf.start, src + n - m, m);
1209 e = ((unsigned char *) lvcc->tx.buf.start) + m;
1211 lvcc->tx.buf.ptr = (u32 *) e;
1220 e = ((unsigned char *) lvcc->tx.buf.ptr) + n;
1221 m = e - (unsigned char *) lvcc->tx.buf.end;
1224 memset(lvcc->tx.buf.ptr, 0, n - m);
1226 memset(lvcc->tx.buf.start, 0, m);
1227 e = ((unsigned char *) lvcc->tx.buf.start) + m;
1229 lvcc->tx.buf.ptr = (u32 *) e;
1236 int i, ptr = ((unsigned char *) lvcc->tx.buf.ptr) -
1237 (unsigned char *) lvcc->tx.buf.start;
1240 ptr, lvcc->vci, lvcc->tx.buf.start, lvcc->tx.buf.ptr,
1241 lvcc->tx.buf.end);
1367 int m = ((const unsigned char *) lvcc->rx.buf.ptr) + n -
1368 ((const unsigned char *) (lvcc->rx.buf.end));
1371 memcpy(dest, lvcc->rx.buf.ptr, n - m);
1372 memcpy(dest + n - m, lvcc->rx.buf.start, m);
1383 u32 *end = &lvcc->rx.buf.start[endptr * 4];
1384 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr);
1386 n += lanai_buf_size(&lvcc->rx.buf);
1387 APRINTK(n >= 0 && n < lanai_buf_size(&lvcc->rx.buf) && !(n & 15),
1389 n, lanai_buf_size(&lvcc->rx.buf));
1391 if ((x = &end[-2]) < lvcc->rx.buf.start)
1392 x = &lvcc->rx.buf.end[-2];
1419 lvcc->rx.buf.ptr = end;
1479 struct lanai_buffer *buf, int max_sdu, int multiplier,
1487 lanai_buf_allocate(buf, size, max_sdu + 32, lanai->pci);
1488 if (unlikely(buf->start == NULL))
1490 if (unlikely(lanai_buf_size(buf) < size))
1493 name, lanai_buf_size(buf));
1494 DPRINTK("Allocated %zu byte %s buffer\n", lanai_buf_size(buf), name);
1502 return lanai_get_sized_buffer(lanai, &lvcc->rx.buf,
1520 return lanai_get_sized_buffer(lanai, &lvcc->tx.buf, max_sdu,
1673 (((unsigned long) lvcc->rx.buf.ptr) -
1674 ((unsigned long) lvcc->rx.buf.start)) + 47;
1676 bytes += lanai_buf_size(&lvcc->rx.buf);
1692 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
2288 lanai_buf_deallocate(&lvcc->rx.buf, lanai->pci);
2298 lanai_buf_deallocate(&lvcc->tx.buf, lanai->pci);
2516 lanai_buf_size(&lvcc->rx.buf),
2526 lanai_buf_size(&lvcc->tx.buf),