Lines Matching refs:db

917 static void bdx_rxdb_destroy(struct rxdb *db)  in bdx_rxdb_destroy()  argument
919 vfree(db); in bdx_rxdb_destroy()
924 struct rxdb *db; in bdx_rxdb_create() local
927 db = vmalloc(sizeof(struct rxdb) in bdx_rxdb_create()
930 if (likely(db != NULL)) { in bdx_rxdb_create()
931 db->stack = (int *)(db + 1); in bdx_rxdb_create()
932 db->elems = (void *)(db->stack + nelem); in bdx_rxdb_create()
933 db->nelem = nelem; in bdx_rxdb_create()
934 db->top = nelem; in bdx_rxdb_create()
936 db->stack[i] = nelem - i - 1; /* to make first allocs in bdx_rxdb_create()
940 return db; in bdx_rxdb_create()
943 static inline int bdx_rxdb_alloc_elem(struct rxdb *db) in bdx_rxdb_alloc_elem() argument
945 BDX_ASSERT(db->top <= 0); in bdx_rxdb_alloc_elem()
946 return db->stack[--(db->top)]; in bdx_rxdb_alloc_elem()
949 static inline void *bdx_rxdb_addr_elem(struct rxdb *db, int n) in bdx_rxdb_addr_elem() argument
951 BDX_ASSERT((n < 0) || (n >= db->nelem)); in bdx_rxdb_addr_elem()
952 return db->elems + n; in bdx_rxdb_addr_elem()
955 static inline int bdx_rxdb_available(struct rxdb *db) in bdx_rxdb_available() argument
957 return db->top; in bdx_rxdb_available()
960 static inline void bdx_rxdb_free_elem(struct rxdb *db, int n) in bdx_rxdb_free_elem() argument
962 BDX_ASSERT((n >= db->nelem) || (n < 0)); in bdx_rxdb_free_elem()
963 db->stack[(db->top)++] = n; in bdx_rxdb_free_elem()
1021 struct rxdb *db = priv->rxdb; in bdx_rx_free_skbs() local
1025 DBG("total=%d free=%d busy=%d\n", db->nelem, bdx_rxdb_available(db), in bdx_rx_free_skbs()
1026 db->nelem - bdx_rxdb_available(db)); in bdx_rx_free_skbs()
1027 while (bdx_rxdb_available(db) > 0) { in bdx_rx_free_skbs()
1028 i = bdx_rxdb_alloc_elem(db); in bdx_rx_free_skbs()
1029 dm = bdx_rxdb_addr_elem(db, i); in bdx_rx_free_skbs()
1032 for (i = 0; i < db->nelem; i++) { in bdx_rx_free_skbs()
1033 dm = bdx_rxdb_addr_elem(db, i); in bdx_rx_free_skbs()
1085 struct rxdb *db = priv->rxdb; in bdx_rx_alloc_skbs() local
1088 dno = bdx_rxdb_available(db) - 1; in bdx_rx_alloc_skbs()
1096 idx = bdx_rxdb_alloc_elem(db); in bdx_rx_alloc_skbs()
1097 dm = bdx_rxdb_addr_elem(db, idx); in bdx_rx_alloc_skbs()
1146 struct rxdb *db; in bdx_recycle_skb() local
1152 db = priv->rxdb; in bdx_recycle_skb()
1153 DBG("db=%p f=%p\n", db, f); in bdx_recycle_skb()
1154 dm = bdx_rxdb_addr_elem(db, rxdd->va_lo); in bdx_recycle_skb()
1199 struct rxdb *db = NULL; in bdx_rx_receive() local
1251 db = priv->rxdb; in bdx_rx_receive()
1252 dm = bdx_rxdb_addr_elem(db, rxdd->va_lo); in bdx_rx_receive()
1268 bdx_rxdb_free_elem(db, rxdd->va_lo); in bdx_rx_receive()
1366 static inline void __bdx_tx_db_ptr_next(struct txdb *db, struct tx_map **pptr) in __bdx_tx_db_ptr_next() argument
1368 BDX_ASSERT(db == NULL || pptr == NULL); /* sanity */ in __bdx_tx_db_ptr_next()
1370 BDX_ASSERT(*pptr != db->rptr && /* expect either read */ in __bdx_tx_db_ptr_next()
1371 *pptr != db->wptr); /* or write pointer */ in __bdx_tx_db_ptr_next()
1373 BDX_ASSERT(*pptr < db->start || /* pointer has to be */ in __bdx_tx_db_ptr_next()
1374 *pptr >= db->end); /* in range */ in __bdx_tx_db_ptr_next()
1377 if (unlikely(*pptr == db->end)) in __bdx_tx_db_ptr_next()
1378 *pptr = db->start; in __bdx_tx_db_ptr_next()
1385 static inline void bdx_tx_db_inc_rptr(struct txdb *db) in bdx_tx_db_inc_rptr() argument
1387 BDX_ASSERT(db->rptr == db->wptr); /* can't read from empty db */ in bdx_tx_db_inc_rptr()
1388 __bdx_tx_db_ptr_next(db, &db->rptr); in bdx_tx_db_inc_rptr()
1395 static inline void bdx_tx_db_inc_wptr(struct txdb *db) in bdx_tx_db_inc_wptr() argument
1397 __bdx_tx_db_ptr_next(db, &db->wptr); in bdx_tx_db_inc_wptr()
1398 BDX_ASSERT(db->rptr == db->wptr); /* we can not get empty db as in bdx_tx_db_inc_wptr()
1471 struct txdb *db = &priv->txdb; in bdx_tx_map_skb() local
1476 db->wptr->len = skb_headlen(skb); in bdx_tx_map_skb()
1477 db->wptr->addr.dma = dma_map_single(&priv->pdev->dev, skb->data, in bdx_tx_map_skb()
1478 db->wptr->len, DMA_TO_DEVICE); in bdx_tx_map_skb()
1479 pbl->len = CPU_CHIP_SWAP32(db->wptr->len); in bdx_tx_map_skb()
1480 pbl->pa_lo = CPU_CHIP_SWAP32(L32_64(db->wptr->addr.dma)); in bdx_tx_map_skb()
1481 pbl->pa_hi = CPU_CHIP_SWAP32(H32_64(db->wptr->addr.dma)); in bdx_tx_map_skb()
1485 bdx_tx_db_inc_wptr(db); in bdx_tx_map_skb()
1491 db->wptr->len = skb_frag_size(frag); in bdx_tx_map_skb()
1492 db->wptr->addr.dma = skb_frag_dma_map(&priv->pdev->dev, frag, in bdx_tx_map_skb()
1497 pbl->len = CPU_CHIP_SWAP32(db->wptr->len); in bdx_tx_map_skb()
1498 pbl->pa_lo = CPU_CHIP_SWAP32(L32_64(db->wptr->addr.dma)); in bdx_tx_map_skb()
1499 pbl->pa_hi = CPU_CHIP_SWAP32(H32_64(db->wptr->addr.dma)); in bdx_tx_map_skb()
1500 bdx_tx_db_inc_wptr(db); in bdx_tx_map_skb()
1504 db->wptr->len = -txd_sizes[nr_frags].bytes; in bdx_tx_map_skb()
1505 db->wptr->addr.skb = skb; in bdx_tx_map_skb()
1506 bdx_tx_db_inc_wptr(db); in bdx_tx_map_skb()
1699 struct txdb *db = &priv->txdb; in bdx_tx_cleanup() local
1712 BDX_ASSERT(db->rptr->len == 0); in bdx_tx_cleanup()
1714 BDX_ASSERT(db->rptr->addr.dma == 0); in bdx_tx_cleanup()
1715 dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma, in bdx_tx_cleanup()
1716 db->rptr->len, DMA_TO_DEVICE); in bdx_tx_cleanup()
1717 bdx_tx_db_inc_rptr(db); in bdx_tx_cleanup()
1718 } while (db->rptr->len > 0); in bdx_tx_cleanup()
1719 tx_level -= db->rptr->len; /* '-' koz len is negative */ in bdx_tx_cleanup()
1722 dev_consume_skb_irq(db->rptr->addr.skb); in bdx_tx_cleanup()
1723 bdx_tx_db_inc_rptr(db); in bdx_tx_cleanup()
1761 struct txdb *db = &priv->txdb; in bdx_tx_free_skbs() local
1764 while (db->rptr != db->wptr) { in bdx_tx_free_skbs()
1765 if (likely(db->rptr->len)) in bdx_tx_free_skbs()
1766 dma_unmap_page(&priv->pdev->dev, db->rptr->addr.dma, in bdx_tx_free_skbs()
1767 db->rptr->len, DMA_TO_DEVICE); in bdx_tx_free_skbs()
1769 dev_kfree_skb(db->rptr->addr.skb); in bdx_tx_free_skbs()
1770 bdx_tx_db_inc_rptr(db); in bdx_tx_free_skbs()