18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright(c) 2017 - 2018 Intel Corporation. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 58c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 108c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 118c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 148c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 158c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 168c2ecf20Sopenharmony_ci * General Public License for more details. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * BSD LICENSE 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 218c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 228c2ecf20Sopenharmony_ci * are met: 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above copyright 258c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 268c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above copyright 278c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 288c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 298c2ecf20Sopenharmony_ci * distribution. 308c2ecf20Sopenharmony_ci * - Neither the name of Intel Corporation nor the names of its 318c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 328c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 358c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 368c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 378c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 388c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 398c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 408c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 418c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 428c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 438c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 448c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 458c2ecf20Sopenharmony_ci * 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* 498c2ecf20Sopenharmony_ci * This file contains HFI1 support for VNIC SDMA functionality 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#include "sdma.h" 538c2ecf20Sopenharmony_ci#include "vnic.h" 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define HFI1_VNIC_SDMA_Q_ACTIVE BIT(0) 568c2ecf20Sopenharmony_ci#define HFI1_VNIC_SDMA_Q_DEFERRED BIT(1) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define HFI1_VNIC_TXREQ_NAME_LEN 32 598c2ecf20Sopenharmony_ci#define HFI1_VNIC_SDMA_DESC_WTRMRK 64 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* 628c2ecf20Sopenharmony_ci * struct vnic_txreq - VNIC transmit descriptor 638c2ecf20Sopenharmony_ci * @txreq: sdma transmit request 648c2ecf20Sopenharmony_ci * @sdma: vnic sdma pointer 658c2ecf20Sopenharmony_ci * @skb: skb to send 668c2ecf20Sopenharmony_ci * @pad: pad buffer 678c2ecf20Sopenharmony_ci * @plen: pad length 688c2ecf20Sopenharmony_ci * @pbc_val: pbc value 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_cistruct vnic_txreq { 718c2ecf20Sopenharmony_ci struct sdma_txreq txreq; 728c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *sdma; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci struct sk_buff *skb; 758c2ecf20Sopenharmony_ci unsigned char pad[HFI1_VNIC_MAX_PAD]; 768c2ecf20Sopenharmony_ci u16 plen; 778c2ecf20Sopenharmony_ci __le64 pbc_val; 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic void vnic_sdma_complete(struct sdma_txreq *txreq, 818c2ecf20Sopenharmony_ci int status) 828c2ecf20Sopenharmony_ci{ 838c2ecf20Sopenharmony_ci struct vnic_txreq *tx = container_of(txreq, struct vnic_txreq, txreq); 848c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = tx->sdma; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci sdma_txclean(vnic_sdma->dd, txreq); 878c2ecf20Sopenharmony_ci dev_kfree_skb_any(tx->skb); 888c2ecf20Sopenharmony_ci kmem_cache_free(vnic_sdma->dd->vnic.txreq_cache, tx); 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic noinline int build_vnic_ulp_payload(struct sdma_engine *sde, 928c2ecf20Sopenharmony_ci struct vnic_txreq *tx) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci int i, ret = 0; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci ret = sdma_txadd_kvaddr( 978c2ecf20Sopenharmony_ci sde->dd, 988c2ecf20Sopenharmony_ci &tx->txreq, 998c2ecf20Sopenharmony_ci tx->skb->data, 1008c2ecf20Sopenharmony_ci skb_headlen(tx->skb)); 1018c2ecf20Sopenharmony_ci if (unlikely(ret)) 1028c2ecf20Sopenharmony_ci goto bail_txadd; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci for (i = 0; i < skb_shinfo(tx->skb)->nr_frags; i++) { 1058c2ecf20Sopenharmony_ci skb_frag_t *frag = &skb_shinfo(tx->skb)->frags[i]; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci /* combine physically continuous fragments later? */ 1088c2ecf20Sopenharmony_ci ret = sdma_txadd_page(sde->dd, 1098c2ecf20Sopenharmony_ci &tx->txreq, 1108c2ecf20Sopenharmony_ci skb_frag_page(frag), 1118c2ecf20Sopenharmony_ci skb_frag_off(frag), 1128c2ecf20Sopenharmony_ci skb_frag_size(frag), 1138c2ecf20Sopenharmony_ci NULL, NULL, NULL); 1148c2ecf20Sopenharmony_ci if (unlikely(ret)) 1158c2ecf20Sopenharmony_ci goto bail_txadd; 1168c2ecf20Sopenharmony_ci } 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci if (tx->plen) 1198c2ecf20Sopenharmony_ci ret = sdma_txadd_kvaddr(sde->dd, &tx->txreq, 1208c2ecf20Sopenharmony_ci tx->pad + HFI1_VNIC_MAX_PAD - tx->plen, 1218c2ecf20Sopenharmony_ci tx->plen); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cibail_txadd: 1248c2ecf20Sopenharmony_ci return ret; 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistatic int build_vnic_tx_desc(struct sdma_engine *sde, 1288c2ecf20Sopenharmony_ci struct vnic_txreq *tx, 1298c2ecf20Sopenharmony_ci u64 pbc) 1308c2ecf20Sopenharmony_ci{ 1318c2ecf20Sopenharmony_ci int ret = 0; 1328c2ecf20Sopenharmony_ci u16 hdrbytes = 2 << 2; /* PBC */ 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci ret = sdma_txinit_ahg( 1358c2ecf20Sopenharmony_ci &tx->txreq, 1368c2ecf20Sopenharmony_ci 0, 1378c2ecf20Sopenharmony_ci hdrbytes + tx->skb->len + tx->plen, 1388c2ecf20Sopenharmony_ci 0, 1398c2ecf20Sopenharmony_ci 0, 1408c2ecf20Sopenharmony_ci NULL, 1418c2ecf20Sopenharmony_ci 0, 1428c2ecf20Sopenharmony_ci vnic_sdma_complete); 1438c2ecf20Sopenharmony_ci if (unlikely(ret)) 1448c2ecf20Sopenharmony_ci goto bail_txadd; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci /* add pbc */ 1478c2ecf20Sopenharmony_ci tx->pbc_val = cpu_to_le64(pbc); 1488c2ecf20Sopenharmony_ci ret = sdma_txadd_kvaddr( 1498c2ecf20Sopenharmony_ci sde->dd, 1508c2ecf20Sopenharmony_ci &tx->txreq, 1518c2ecf20Sopenharmony_ci &tx->pbc_val, 1528c2ecf20Sopenharmony_ci hdrbytes); 1538c2ecf20Sopenharmony_ci if (unlikely(ret)) 1548c2ecf20Sopenharmony_ci goto bail_txadd; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci /* add the ulp payload */ 1578c2ecf20Sopenharmony_ci ret = build_vnic_ulp_payload(sde, tx); 1588c2ecf20Sopenharmony_cibail_txadd: 1598c2ecf20Sopenharmony_ci return ret; 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/* setup the last plen bypes of pad */ 1638c2ecf20Sopenharmony_cistatic inline void hfi1_vnic_update_pad(unsigned char *pad, u8 plen) 1648c2ecf20Sopenharmony_ci{ 1658c2ecf20Sopenharmony_ci pad[HFI1_VNIC_MAX_PAD - 1] = plen - OPA_VNIC_ICRC_TAIL_LEN; 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ciint hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx, 1698c2ecf20Sopenharmony_ci struct hfi1_vnic_vport_info *vinfo, 1708c2ecf20Sopenharmony_ci struct sk_buff *skb, u64 pbc, u8 plen) 1718c2ecf20Sopenharmony_ci{ 1728c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; 1738c2ecf20Sopenharmony_ci struct sdma_engine *sde = vnic_sdma->sde; 1748c2ecf20Sopenharmony_ci struct vnic_txreq *tx; 1758c2ecf20Sopenharmony_ci int ret = -ECOMM; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci if (unlikely(READ_ONCE(vnic_sdma->state) != HFI1_VNIC_SDMA_Q_ACTIVE)) 1788c2ecf20Sopenharmony_ci goto tx_err; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci if (unlikely(!sde || !sdma_running(sde))) 1818c2ecf20Sopenharmony_ci goto tx_err; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci tx = kmem_cache_alloc(dd->vnic.txreq_cache, GFP_ATOMIC); 1848c2ecf20Sopenharmony_ci if (unlikely(!tx)) { 1858c2ecf20Sopenharmony_ci ret = -ENOMEM; 1868c2ecf20Sopenharmony_ci goto tx_err; 1878c2ecf20Sopenharmony_ci } 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci tx->sdma = vnic_sdma; 1908c2ecf20Sopenharmony_ci tx->skb = skb; 1918c2ecf20Sopenharmony_ci hfi1_vnic_update_pad(tx->pad, plen); 1928c2ecf20Sopenharmony_ci tx->plen = plen; 1938c2ecf20Sopenharmony_ci ret = build_vnic_tx_desc(sde, tx, pbc); 1948c2ecf20Sopenharmony_ci if (unlikely(ret)) 1958c2ecf20Sopenharmony_ci goto free_desc; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci ret = sdma_send_txreq(sde, iowait_get_ib_work(&vnic_sdma->wait), 1988c2ecf20Sopenharmony_ci &tx->txreq, vnic_sdma->pkts_sent); 1998c2ecf20Sopenharmony_ci /* When -ECOMM, sdma callback will be called with ABORT status */ 2008c2ecf20Sopenharmony_ci if (unlikely(ret && unlikely(ret != -ECOMM))) 2018c2ecf20Sopenharmony_ci goto free_desc; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci if (!ret) { 2048c2ecf20Sopenharmony_ci vnic_sdma->pkts_sent = true; 2058c2ecf20Sopenharmony_ci iowait_starve_clear(vnic_sdma->pkts_sent, &vnic_sdma->wait); 2068c2ecf20Sopenharmony_ci } 2078c2ecf20Sopenharmony_ci return ret; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_cifree_desc: 2108c2ecf20Sopenharmony_ci sdma_txclean(dd, &tx->txreq); 2118c2ecf20Sopenharmony_ci kmem_cache_free(dd->vnic.txreq_cache, tx); 2128c2ecf20Sopenharmony_citx_err: 2138c2ecf20Sopenharmony_ci if (ret != -EBUSY) 2148c2ecf20Sopenharmony_ci dev_kfree_skb_any(skb); 2158c2ecf20Sopenharmony_ci else 2168c2ecf20Sopenharmony_ci vnic_sdma->pkts_sent = false; 2178c2ecf20Sopenharmony_ci return ret; 2188c2ecf20Sopenharmony_ci} 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* 2218c2ecf20Sopenharmony_ci * hfi1_vnic_sdma_sleep - vnic sdma sleep function 2228c2ecf20Sopenharmony_ci * 2238c2ecf20Sopenharmony_ci * This function gets called from sdma_send_txreq() when there are not enough 2248c2ecf20Sopenharmony_ci * sdma descriptors available to send the packet. It adds Tx queue's wait 2258c2ecf20Sopenharmony_ci * structure to sdma engine's dmawait list to be woken up when descriptors 2268c2ecf20Sopenharmony_ci * become available. 2278c2ecf20Sopenharmony_ci */ 2288c2ecf20Sopenharmony_cistatic int hfi1_vnic_sdma_sleep(struct sdma_engine *sde, 2298c2ecf20Sopenharmony_ci struct iowait_work *wait, 2308c2ecf20Sopenharmony_ci struct sdma_txreq *txreq, 2318c2ecf20Sopenharmony_ci uint seq, 2328c2ecf20Sopenharmony_ci bool pkts_sent) 2338c2ecf20Sopenharmony_ci{ 2348c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = 2358c2ecf20Sopenharmony_ci container_of(wait->iow, struct hfi1_vnic_sdma, wait); 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci write_seqlock(&sde->waitlock); 2388c2ecf20Sopenharmony_ci if (sdma_progress(sde, seq, txreq)) { 2398c2ecf20Sopenharmony_ci write_sequnlock(&sde->waitlock); 2408c2ecf20Sopenharmony_ci return -EAGAIN; 2418c2ecf20Sopenharmony_ci } 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci vnic_sdma->state = HFI1_VNIC_SDMA_Q_DEFERRED; 2448c2ecf20Sopenharmony_ci if (list_empty(&vnic_sdma->wait.list)) { 2458c2ecf20Sopenharmony_ci iowait_get_priority(wait->iow); 2468c2ecf20Sopenharmony_ci iowait_queue(pkts_sent, wait->iow, &sde->dmawait); 2478c2ecf20Sopenharmony_ci } 2488c2ecf20Sopenharmony_ci write_sequnlock(&sde->waitlock); 2498c2ecf20Sopenharmony_ci return -EBUSY; 2508c2ecf20Sopenharmony_ci} 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* 2538c2ecf20Sopenharmony_ci * hfi1_vnic_sdma_wakeup - vnic sdma wakeup function 2548c2ecf20Sopenharmony_ci * 2558c2ecf20Sopenharmony_ci * This function gets called when SDMA descriptors becomes available and Tx 2568c2ecf20Sopenharmony_ci * queue's wait structure was previously added to sdma engine's dmawait list. 2578c2ecf20Sopenharmony_ci * It notifies the upper driver about Tx queue wakeup. 2588c2ecf20Sopenharmony_ci */ 2598c2ecf20Sopenharmony_cistatic void hfi1_vnic_sdma_wakeup(struct iowait *wait, int reason) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = 2628c2ecf20Sopenharmony_ci container_of(wait, struct hfi1_vnic_sdma, wait); 2638c2ecf20Sopenharmony_ci struct hfi1_vnic_vport_info *vinfo = vnic_sdma->vinfo; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; 2668c2ecf20Sopenharmony_ci if (__netif_subqueue_stopped(vinfo->netdev, vnic_sdma->q_idx)) 2678c2ecf20Sopenharmony_ci netif_wake_subqueue(vinfo->netdev, vnic_sdma->q_idx); 2688c2ecf20Sopenharmony_ci}; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ciinline bool hfi1_vnic_sdma_write_avail(struct hfi1_vnic_vport_info *vinfo, 2718c2ecf20Sopenharmony_ci u8 q_idx) 2728c2ecf20Sopenharmony_ci{ 2738c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[q_idx]; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci return (READ_ONCE(vnic_sdma->state) == HFI1_VNIC_SDMA_Q_ACTIVE); 2768c2ecf20Sopenharmony_ci} 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_civoid hfi1_vnic_sdma_init(struct hfi1_vnic_vport_info *vinfo) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci int i; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci for (i = 0; i < vinfo->num_tx_q; i++) { 2838c2ecf20Sopenharmony_ci struct hfi1_vnic_sdma *vnic_sdma = &vinfo->sdma[i]; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci iowait_init(&vnic_sdma->wait, 0, NULL, NULL, 2868c2ecf20Sopenharmony_ci hfi1_vnic_sdma_sleep, 2878c2ecf20Sopenharmony_ci hfi1_vnic_sdma_wakeup, NULL, NULL); 2888c2ecf20Sopenharmony_ci vnic_sdma->sde = &vinfo->dd->per_sdma[i]; 2898c2ecf20Sopenharmony_ci vnic_sdma->dd = vinfo->dd; 2908c2ecf20Sopenharmony_ci vnic_sdma->vinfo = vinfo; 2918c2ecf20Sopenharmony_ci vnic_sdma->q_idx = i; 2928c2ecf20Sopenharmony_ci vnic_sdma->state = HFI1_VNIC_SDMA_Q_ACTIVE; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ci /* Add a free descriptor watermark for wakeups */ 2958c2ecf20Sopenharmony_ci if (vnic_sdma->sde->descq_cnt > HFI1_VNIC_SDMA_DESC_WTRMRK) { 2968c2ecf20Sopenharmony_ci struct iowait_work *work; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&vnic_sdma->stx.list); 2998c2ecf20Sopenharmony_ci vnic_sdma->stx.num_desc = HFI1_VNIC_SDMA_DESC_WTRMRK; 3008c2ecf20Sopenharmony_ci work = iowait_get_ib_work(&vnic_sdma->wait); 3018c2ecf20Sopenharmony_ci list_add_tail(&vnic_sdma->stx.list, &work->tx_head); 3028c2ecf20Sopenharmony_ci } 3038c2ecf20Sopenharmony_ci } 3048c2ecf20Sopenharmony_ci} 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ciint hfi1_vnic_txreq_init(struct hfi1_devdata *dd) 3078c2ecf20Sopenharmony_ci{ 3088c2ecf20Sopenharmony_ci char buf[HFI1_VNIC_TXREQ_NAME_LEN]; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci snprintf(buf, sizeof(buf), "hfi1_%u_vnic_txreq_cache", dd->unit); 3118c2ecf20Sopenharmony_ci dd->vnic.txreq_cache = kmem_cache_create(buf, 3128c2ecf20Sopenharmony_ci sizeof(struct vnic_txreq), 3138c2ecf20Sopenharmony_ci 0, SLAB_HWCACHE_ALIGN, 3148c2ecf20Sopenharmony_ci NULL); 3158c2ecf20Sopenharmony_ci if (!dd->vnic.txreq_cache) 3168c2ecf20Sopenharmony_ci return -ENOMEM; 3178c2ecf20Sopenharmony_ci return 0; 3188c2ecf20Sopenharmony_ci} 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_civoid hfi1_vnic_txreq_deinit(struct hfi1_devdata *dd) 3218c2ecf20Sopenharmony_ci{ 3228c2ecf20Sopenharmony_ci kmem_cache_destroy(dd->vnic.txreq_cache); 3238c2ecf20Sopenharmony_ci dd->vnic.txreq_cache = NULL; 3248c2ecf20Sopenharmony_ci} 325