* Release buffers to hardware bpool (buffer-pool) * * @param rxq * Receive queue pointer. * @param num * Number of buffers to release to bpool. * * @return * 0 on success, negative error value otherwise. */
| 1908 | * 0 on success, negative error value otherwise. |
| 1909 | */ |
| 1910 | static int |
| 1911 | mrvl_fill_bpool(struct mrvl_rxq *rxq, int num) |
| 1912 | { |
| 1913 | struct buff_release_entry entries[num]; |
| 1914 | struct rte_mbuf *mbufs[num]; |
| 1915 | int i, ret; |
| 1916 | unsigned int core_id; |
| 1917 | struct pp2_hif *hif; |
| 1918 | struct pp2_bpool *bpool; |
| 1919 | |
| 1920 | core_id = rte_lcore_id(); |
| 1921 | if (core_id == LCORE_ID_ANY) |
| 1922 | core_id = rte_get_main_lcore(); |
| 1923 | |
| 1924 | hif = mrvl_get_hif(rxq->priv, core_id); |
| 1925 | if (!hif) |
| 1926 | return -1; |
| 1927 | |
| 1928 | bpool = rxq->priv->bpool; |
| 1929 | |
| 1930 | ret = rte_pktmbuf_alloc_bulk(rxq->mp, mbufs, num); |
| 1931 | if (ret) |
| 1932 | return ret; |
| 1933 | |
| 1934 | if (cookie_addr_high == MRVL_COOKIE_ADDR_INVALID) |
| 1935 | cookie_addr_high = |
| 1936 | (uint64_t)mbufs[0] & MRVL_COOKIE_HIGH_ADDR_MASK; |
| 1937 | |
| 1938 | for (i = 0; i < num; i++) { |
| 1939 | if (((uint64_t)mbufs[i] & MRVL_COOKIE_HIGH_ADDR_MASK) |
| 1940 | != cookie_addr_high) { |
| 1941 | MRVL_LOG(ERR, |
| 1942 | "mbuf virtual addr high is out of range " |
| 1943 | "0x%x instead of 0x%x\n", |
| 1944 | (uint32_t)((uint64_t)mbufs[i] >> 32), |
| 1945 | (uint32_t)(cookie_addr_high >> 32)); |
| 1946 | goto out; |
| 1947 | } |
| 1948 | |
| 1949 | entries[i].buff.addr = |
| 1950 | rte_mbuf_data_iova_default(mbufs[i]); |
| 1951 | entries[i].buff.cookie = (uintptr_t)mbufs[i]; |
| 1952 | entries[i].bpool = bpool; |
| 1953 | } |
| 1954 | |
| 1955 | pp2_bpool_put_buffs(hif, entries, (uint16_t *)&i); |
| 1956 | mrvl_port_bpool_size[bpool->pp2_id][bpool->id][core_id] += i; |
| 1957 | |
| 1958 | if (i != num) |
| 1959 | goto out; |
| 1960 | |
| 1961 | return 0; |
| 1962 | out: |
| 1963 | for (; i < num; i++) |
| 1964 | rte_pktmbuf_free(mbufs[i]); |
| 1965 | |
| 1966 | return -1; |
| 1967 | } |
no test coverage detected