Print this page
10090 rt2860_free_rx_ring doesn't need to check for NULL array
   1 /*
   2  * Copyright 2017 Gary Mills
   3  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
   4  * Use is subject to license terms.

   5  */
   6 
   7 /*
   8  * Copyright (c) 2007, 2008
   9  *      Damien Bergamini <damien.bergamini@free.fr>
  10  *
  11  * Permission to use, copy, modify, and distribute this software for any
  12  * purpose with or without fee is hereby granted, provided that the above
  13  * copyright notice and this permission notice appear in all copies.
  14  *
  15  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  16  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  17  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  18  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  21  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22  */
  23 
  24 /*


 883 
 884         for (i = 0; i < RT2860_RX_RING_COUNT; i++)
 885                 ring->rxd[i].sdl0 &= ~LE_16(RT2860_RX_DDONE);
 886 
 887         RT2860_DMA_SYNC(ring->rxdesc_dma, DDI_DMA_SYNC_FORDEV);
 888 
 889         ring->cur = 0;
 890 }
 891 
 892 /*ARGSUSED*/
 893 static void
 894 rt2860_free_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring)
 895 {
 896         struct rt2860_rx_data   *data;
 897         int                     i, count;
 898 
 899         if (ring->rxd != NULL)
 900                 rt2860_free_dma_mem(&ring->rxdesc_dma);
 901 
 902         count = RT2860_RX_RING_COUNT;
 903         if (ring->data != NULL) {
 904                 for (i = 0; i < count; i++) {
 905                         data = &ring->data[i];
 906                         rt2860_free_dma_mem(&data->rxbuf_dma);
 907                 }
 908         }
 909 }
 910 
 911 static int
 912 rt2860_alloc_tx_pool(struct rt2860_softc *sc)
 913 {
 914         struct rt2860_tx_data   *data;
 915         int                     i, err, size;
 916 
 917         size = RT2860_TX_POOL_COUNT * sizeof (struct rt2860_txwi);
 918 
 919         /* init data_pool early in case of failure.. */
 920         SLIST_INIT(&sc->data_pool);
 921 
 922         err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size,
 923             &rt2860_desc_accattr, DDI_DMA_CONSISTENT,
 924             DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
 925             &sc->txpool_dma);
 926         if (err != DDI_SUCCESS) {
 927                 RWN_DEBUG(RT2860_DBG_DMA, "rwn: rt2860_alloc_tx_pool(): "
 928                     "failed to alloc dma mem\n");


   1 /*
   2  * Copyright 2017 Gary Mills
   3  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
   4  * Use is subject to license terms.
   5  * Copyright (c) 2018, Joyent, Inc.
   6  */
   7 
   8 /*
   9  * Copyright (c) 2007, 2008
  10  *      Damien Bergamini <damien.bergamini@free.fr>
  11  *
  12  * Permission to use, copy, modify, and distribute this software for any
  13  * purpose with or without fee is hereby granted, provided that the above
  14  * copyright notice and this permission notice appear in all copies.
  15  *
  16  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  17  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  18  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  19  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  21  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  22  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23  */
  24 
  25 /*


 884 
 885         for (i = 0; i < RT2860_RX_RING_COUNT; i++)
 886                 ring->rxd[i].sdl0 &= ~LE_16(RT2860_RX_DDONE);
 887 
 888         RT2860_DMA_SYNC(ring->rxdesc_dma, DDI_DMA_SYNC_FORDEV);
 889 
 890         ring->cur = 0;
 891 }
 892 
 893 /*ARGSUSED*/
 894 static void
 895 rt2860_free_rx_ring(struct rt2860_softc *sc, struct rt2860_rx_ring *ring)
 896 {
 897         struct rt2860_rx_data   *data;
 898         int                     i, count;
 899 
 900         if (ring->rxd != NULL)
 901                 rt2860_free_dma_mem(&ring->rxdesc_dma);
 902 
 903         count = RT2860_RX_RING_COUNT;
 904 
 905         for (i = 0; i < count; i++) {
 906                 data = &ring->data[i];
 907                 rt2860_free_dma_mem(&data->rxbuf_dma);
 908         }

 909 }
 910 
 911 static int
 912 rt2860_alloc_tx_pool(struct rt2860_softc *sc)
 913 {
 914         struct rt2860_tx_data   *data;
 915         int                     i, err, size;
 916 
 917         size = RT2860_TX_POOL_COUNT * sizeof (struct rt2860_txwi);
 918 
 919         /* init data_pool early in case of failure.. */
 920         SLIST_INIT(&sc->data_pool);
 921 
 922         err = rt2860_alloc_dma_mem(sc->sc_dev, &rt2860_dma_attr, size,
 923             &rt2860_desc_accattr, DDI_DMA_CONSISTENT,
 924             DDI_DMA_RDWR | DDI_DMA_CONSISTENT,
 925             &sc->txpool_dma);
 926         if (err != DDI_SUCCESS) {
 927                 RWN_DEBUG(RT2860_DBG_DMA, "rwn: rt2860_alloc_tx_pool(): "
 928                     "failed to alloc dma mem\n");