Lines Matching refs:db
73 struct tn40_rxdb *db; in tn40_rxdb_alloc() local
76 db = vzalloc(size); in tn40_rxdb_alloc()
77 if (db) { in tn40_rxdb_alloc()
78 db->stack = (int *)(db + 1); in tn40_rxdb_alloc()
79 db->elems = (void *)(db->stack + nelem); in tn40_rxdb_alloc()
80 db->nelem = nelem; in tn40_rxdb_alloc()
81 db->top = nelem; in tn40_rxdb_alloc()
84 db->stack[i] = nelem - i - 1; in tn40_rxdb_alloc()
86 return db; in tn40_rxdb_alloc()
89 static void tn40_rxdb_free(struct tn40_rxdb *db) in tn40_rxdb_free() argument
91 vfree(db); in tn40_rxdb_free()
94 static int tn40_rxdb_alloc_elem(struct tn40_rxdb *db) in tn40_rxdb_alloc_elem() argument
96 return db->stack[--db->top]; in tn40_rxdb_alloc_elem()
99 static void *tn40_rxdb_addr_elem(struct tn40_rxdb *db, unsigned int n) in tn40_rxdb_addr_elem() argument
101 return db->elems + n; in tn40_rxdb_addr_elem()
104 static int tn40_rxdb_available(struct tn40_rxdb *db) in tn40_rxdb_available() argument
106 return db->top; in tn40_rxdb_available()
109 static void tn40_rxdb_free_elem(struct tn40_rxdb *db, unsigned int n) in tn40_rxdb_free_elem() argument
111 db->stack[db->top++] = n; in tn40_rxdb_free_elem()
178 struct tn40_rxdb *db = priv->rxdb0; in tn40_rx_free_buffers() local
182 netdev_dbg(priv->ndev, "total =%d free =%d busy =%d\n", db->nelem, in tn40_rx_free_buffers()
183 tn40_rxdb_available(db), in tn40_rx_free_buffers()
184 db->nelem - tn40_rxdb_available(db)); in tn40_rx_free_buffers()
186 for (i = 0; i < db->nelem; i++) { in tn40_rx_free_buffers()
187 dm = tn40_rxdb_addr_elem(db, i); in tn40_rx_free_buffers()
243 struct tn40_rxdb *db = priv->rxdb0; in tn40_rx_alloc_buffers() local
248 dno = tn40_rxdb_available(db) - 1; in tn40_rx_alloc_buffers()
254 idx = tn40_rxdb_alloc_elem(db); in tn40_rx_alloc_buffers()
256 dm = tn40_rxdb_addr_elem(db, idx); in tn40_rx_alloc_buffers()
289 struct tn40_rxdb *db = NULL; in tn40_rx_receive() local
303 db = priv->rxdb0; in tn40_rx_receive()
363 dm = tn40_rxdb_addr_elem(db, idx); in tn40_rx_receive()
397 tn40_rxdb_free_elem(db, idx); in tn40_rx_receive()
458 static void tn40_do_tx_db_ptr_next(struct tn40_txdb *db, in tn40_do_tx_db_ptr_next() argument
462 if (unlikely(*pptr == db->end)) in tn40_do_tx_db_ptr_next()
463 *pptr = db->start; in tn40_do_tx_db_ptr_next()
466 static void tn40_tx_db_inc_rptr(struct tn40_txdb *db) in tn40_tx_db_inc_rptr() argument
468 tn40_do_tx_db_ptr_next(db, &db->rptr); in tn40_tx_db_inc_rptr()
471 static void tn40_tx_db_inc_wptr(struct tn40_txdb *db) in tn40_tx_db_inc_wptr() argument
473 tn40_do_tx_db_ptr_next(db, &db->wptr); in tn40_tx_db_inc_wptr()
548 static void tn40_txdb_set(struct tn40_txdb *db, dma_addr_t dma, int len) in tn40_txdb_set() argument
550 db->wptr->len = len; in tn40_txdb_set()
551 db->wptr->addr.dma = dma; in tn40_txdb_set()
580 struct tn40_txdb *db = &priv->txdb; in tn40_tx_map_skb() local
601 tn40_txdb_set(db, dma, len); in tn40_tx_map_skb()
602 tn40_pbl_set(pbl++, db->wptr->addr.dma, db->wptr->len); in tn40_tx_map_skb()
603 *pkt_len = db->wptr->len; in tn40_tx_map_skb()
620 tn40_tx_db_inc_wptr(db); in tn40_tx_map_skb()
621 tn40_txdb_set(db, info[i].dma, info[i].size); in tn40_tx_map_skb()
622 tn40_pbl_set(pbl++, db->wptr->addr.dma, db->wptr->len); in tn40_tx_map_skb()
623 *pkt_len += db->wptr->len; in tn40_tx_map_skb()
631 tn40_tx_db_inc_wptr(db); in tn40_tx_map_skb()
632 db->wptr->len = -tn40_txd_sizes[nr_frags].bytes; in tn40_tx_map_skb()
633 db->wptr->addr.skb = skb; in tn40_tx_map_skb()
634 tn40_tx_db_inc_wptr(db); in tn40_tx_map_skb()
638 dma_unmap_page(&priv->pdev->dev, db->wptr->addr.dma, db->wptr->len, in tn40_tx_map_skb()
821 struct tn40_txdb *db = &priv->txdb; in tn40_tx_cleanup() local
833 dma_addr_t addr = db->rptr->addr.dma; in tn40_tx_cleanup()
834 size_t size = db->rptr->len; in tn40_tx_cleanup()
840 tn40_tx_db_inc_rptr(db); in tn40_tx_cleanup()
841 } while (db->rptr->len > 0); in tn40_tx_cleanup()
842 tx_level -= db->rptr->len; /* '-' Because the len is negative */ in tn40_tx_cleanup()
845 dev_kfree_skb_any(db->rptr->addr.skb); in tn40_tx_cleanup()
847 db->rptr->addr.skb, -db->rptr->len); in tn40_tx_cleanup()
848 tn40_tx_db_inc_rptr(db); in tn40_tx_cleanup()
875 struct tn40_txdb *db = &priv->txdb; in tn40_tx_free_skbs() local
877 while (db->rptr != db->wptr) { in tn40_tx_free_skbs()
878 if (likely(db->rptr->len)) in tn40_tx_free_skbs()
879 dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma, in tn40_tx_free_skbs()
880 db->rptr->len, DMA_TO_DEVICE); in tn40_tx_free_skbs()
882 dev_kfree_skb(db->rptr->addr.skb); in tn40_tx_free_skbs()
883 tn40_tx_db_inc_rptr(db); in tn40_tx_free_skbs()