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)),
783 (((lanai_buf_size(&lvcc->tx.buf) / 1024) * HZ) >> 7);
1137 r -= ((unsigned long) lvcc->tx.buf.ptr) -
1138 ((unsigned long) lvcc->tx.buf.start);
1141 r += lanai_buf_size(&lvcc->tx.buf);
1162 APRINTK((((unsigned long) lvcc->tx.buf.ptr) & 15) == 0,
1163 "vcc_tx_add_aal5_descriptor: bad ptr=%p\n", lvcc->tx.buf.ptr);
1164 lvcc->tx.buf.ptr += 4; /* Hope the values REALLY don't matter */
1165 pos = ((unsigned char *) lvcc->tx.buf.ptr) -
1166 (unsigned char *) lvcc->tx.buf.start;
1170 lvcc->tx.buf.start, lvcc->tx.buf.ptr, lvcc->tx.buf.end);
1171 pos = (pos + len) & (lanai_buf_size(&lvcc->tx.buf) - 1);
1175 lvcc->tx.buf.start, lvcc->tx.buf.ptr, lvcc->tx.buf.end);
1176 lvcc->tx.buf.ptr[-1] =
1180 if (lvcc->tx.buf.ptr >= lvcc->tx.buf.end)
1181 lvcc->tx.buf.ptr = lvcc->tx.buf.start;
1188 APRINTK((((unsigned long) lvcc->tx.buf.ptr) & 15) == 8,
1189 "vcc_tx_add_aal5_trailer: bad ptr=%p\n", lvcc->tx.buf.ptr);
1190 lvcc->tx.buf.ptr += 2;
1191 lvcc->tx.buf.ptr[-2] = cpu_to_be32((uu << 24) | (cpi << 16) | len);
1192 if (lvcc->tx.buf.ptr >= lvcc->tx.buf.end)
1193 lvcc->tx.buf.ptr = lvcc->tx.buf.start;
1201 e = ((unsigned char *) lvcc->tx.buf.ptr) + n;
1202 m = e - (unsigned char *) lvcc->tx.buf.end;
1205 memcpy(lvcc->tx.buf.ptr, src, n - m);
1207 memcpy(lvcc->tx.buf.start, src + n - m, m);
1208 e = ((unsigned char *) lvcc->tx.buf.start) + m;
1210 lvcc->tx.buf.ptr = (u32 *) e;
1219 e = ((unsigned char *) lvcc->tx.buf.ptr) + n;
1220 m = e - (unsigned char *) lvcc->tx.buf.end;
1223 memset(lvcc->tx.buf.ptr, 0, n - m);
1225 memset(lvcc->tx.buf.start, 0, m);
1226 e = ((unsigned char *) lvcc->tx.buf.start) + m;
1228 lvcc->tx.buf.ptr = (u32 *) e;
1235 int i, ptr = ((unsigned char *) lvcc->tx.buf.ptr) -
1236 (unsigned char *) lvcc->tx.buf.start;
1239 ptr, lvcc->vci, lvcc->tx.buf.start, lvcc->tx.buf.ptr,
1240 lvcc->tx.buf.end);
1366 int m = ((const unsigned char *) lvcc->rx.buf.ptr) + n -
1367 ((const unsigned char *) (lvcc->rx.buf.end));
1370 memcpy(dest, lvcc->rx.buf.ptr, n - m);
1371 memcpy(dest + n - m, lvcc->rx.buf.start, m);
1382 u32 *end = &lvcc->rx.buf.start[endptr * 4];
1383 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr);
1385 n += lanai_buf_size(&lvcc->rx.buf);
1386 APRINTK(n >= 0 && n < lanai_buf_size(&lvcc->rx.buf) && !(n & 15),
1388 n, lanai_buf_size(&lvcc->rx.buf));
1390 if ((x = &end[-2]) < lvcc->rx.buf.start)
1391 x = &lvcc->rx.buf.end[-2];
1418 lvcc->rx.buf.ptr = end;
1478 struct lanai_buffer *buf, int max_sdu, int multiplier,
1486 lanai_buf_allocate(buf, size, max_sdu + 32, lanai->pci);
1487 if (unlikely(buf->start == NULL))
1489 if (unlikely(lanai_buf_size(buf) < size))
1492 name, lanai_buf_size(buf));
1493 DPRINTK("Allocated %zu byte %s buffer\n", lanai_buf_size(buf), name);
1501 return lanai_get_sized_buffer(lanai, &lvcc->rx.buf,
1519 return lanai_get_sized_buffer(lanai, &lvcc->tx.buf, max_sdu,
1672 (((unsigned long) lvcc->rx.buf.ptr) -
1673 ((unsigned long) lvcc->rx.buf.start)) + 47;
1675 bytes += lanai_buf_size(&lvcc->rx.buf);
1691 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
2287 lanai_buf_deallocate(&lvcc->rx.buf, lanai->pci);
2297 lanai_buf_deallocate(&lvcc->tx.buf, lanai->pci);
2515 lanai_buf_size(&lvcc->rx.buf),
2525 lanai_buf_size(&lvcc->tx.buf),