* * Allocate DMA resources for RX buffers as well as memory for the RX * mbuf map, direct RX cluster pointer map and RX cluster bus address * map. RX DMA map, RX mbuf map, direct RX cluster pointer map and * RX cluster map are kept in a iflib_sw_rx_desc_array structure. * Since we use use one entry in iflib_sw_rx_desc_array per received * packet, the maximum number of entries we'll ne
| 1882 | * |
| 1883 | **********************************************************************/ |
| 1884 | static int |
| 1885 | iflib_rxsd_alloc(iflib_rxq_t rxq) |
| 1886 | { |
| 1887 | if_ctx_t ctx = rxq->ifr_ctx; |
| 1888 | if_shared_ctx_t sctx = ctx->ifc_sctx; |
| 1889 | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; |
| 1890 | device_t dev = ctx->ifc_dev; |
| 1891 | iflib_fl_t fl; |
| 1892 | int err; |
| 1893 | |
| 1894 | MPASS(scctx->isc_nrxd[0] > 0); |
| 1895 | MPASS(scctx->isc_nrxd[rxq->ifr_fl_offset] > 0); |
| 1896 | |
| 1897 | fl = rxq->ifr_fl; |
| 1898 | for (int i = 0; i < rxq->ifr_nfl; i++, fl++) { |
| 1899 | fl->ifl_size = scctx->isc_nrxd[rxq->ifr_fl_offset]; /* this isn't necessarily the same */ |
| 1900 | /* Set up DMA tag for RX buffers. */ |
| 1901 | err = bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ |
| 1902 | 1, 0, /* alignment, bounds */ |
| 1903 | BUS_SPACE_MAXADDR, /* lowaddr */ |
| 1904 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 1905 | NULL, NULL, /* filter, filterarg */ |
| 1906 | sctx->isc_rx_maxsize, /* maxsize */ |
| 1907 | sctx->isc_rx_nsegments, /* nsegments */ |
| 1908 | sctx->isc_rx_maxsegsize, /* maxsegsize */ |
| 1909 | 0, /* flags */ |
| 1910 | NULL, /* lockfunc */ |
| 1911 | NULL, /* lockarg */ |
| 1912 | &fl->ifl_buf_tag); |
| 1913 | if (err) { |
| 1914 | device_printf(dev, |
| 1915 | "Unable to allocate RX DMA tag: %d\n", err); |
| 1916 | goto fail; |
| 1917 | } |
| 1918 | |
| 1919 | /* Allocate memory for the RX mbuf map. */ |
| 1920 | if (!(fl->ifl_sds.ifsd_m = |
| 1921 | (struct mbuf **) malloc(sizeof(struct mbuf *) * |
| 1922 | scctx->isc_nrxd[rxq->ifr_fl_offset], M_IFLIB, M_NOWAIT | M_ZERO))) { |
| 1923 | device_printf(dev, |
| 1924 | "Unable to allocate RX mbuf map memory\n"); |
| 1925 | err = ENOMEM; |
| 1926 | goto fail; |
| 1927 | } |
| 1928 | |
| 1929 | /* Allocate memory for the direct RX cluster pointer map. */ |
| 1930 | if (!(fl->ifl_sds.ifsd_cl = |
| 1931 | (caddr_t *) malloc(sizeof(caddr_t) * |
| 1932 | scctx->isc_nrxd[rxq->ifr_fl_offset], M_IFLIB, M_NOWAIT | M_ZERO))) { |
| 1933 | device_printf(dev, |
| 1934 | "Unable to allocate RX cluster map memory\n"); |
| 1935 | err = ENOMEM; |
| 1936 | goto fail; |
| 1937 | } |
| 1938 | |
| 1939 | /* Allocate memory for the RX cluster bus address map. */ |
| 1940 | if (!(fl->ifl_sds.ifsd_ba = |
| 1941 | (bus_addr_t *) malloc(sizeof(bus_addr_t) * |
no test coverage detected