if (fnic->stop_rx_link_events) {
list_del(&cur_frame->links);
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- kfree(cur_frame->fp);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
mempool_free(cur_frame, fnic->frame_elem_pool);
return;
}
fnic_fdls_recv_frame(&fnic->iport, cur_frame->fp,
cur_frame->frame_len, fchdr_offset);
- kfree(cur_frame->fp);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
mempool_free(cur_frame, fnic->frame_elem_pool);
}
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
if (fnic->stop_rx_link_events) {
list_del(&cur_frame->links);
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
- kfree(cur_frame->fp);
- kfree(cur_frame);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
+ mempool_free(cur_frame, fnic->frame_elem_pool);
return;
}
list_del(&cur_frame->links);
if (fdls_fip_recv_frame(fnic, cur_frame->fp)) {
- kfree(cur_frame->fp);
- kfree(cur_frame);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
+ mempool_free(cur_frame, fnic->frame_elem_pool);
}
}
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
eh = (struct ethhdr *) fp;
if ((eh->h_proto == cpu_to_be16(ETH_P_FIP)) && (fnic->iport.usefip)) {
- fip_fr_elem = (struct fnic_frame_list *)
- kzalloc_obj(struct fnic_frame_list, GFP_ATOMIC);
+ fip_fr_elem = mempool_alloc(fnic->frame_elem_pool, GFP_ATOMIC);
if (!fip_fr_elem)
return 0;
+ memset(fip_fr_elem, 0, sizeof(struct fnic_frame_list));
fip_fr_elem->fp = fp;
spin_lock_irqsave(&fnic->fnic_lock, flags);
list_add_tail(&fip_fr_elem->links, &fnic->fip_frame_queue);
return;
drop:
- kfree(fp);
+ mempool_free(fp, fnic->frame_recv_pool);
}
static int fnic_rq_cmpl_handler_cont(struct vnic_dev *vdev,
int ret;
len = FNIC_FRAME_HT_ROOM;
- buf = kmalloc(len, GFP_ATOMIC);
+ buf = mempool_alloc(fnic->frame_recv_pool, GFP_ATOMIC);
if (!buf) {
FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num,
"Unable to allocate RQ buffer of size: %d\n", len);
fnic_queue_rq_desc(rq, buf, pa, len);
return 0;
free_buf:
- kfree(buf);
+ mempool_free(buf, fnic->frame_recv_pool);
return ret;
}
dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
DMA_FROM_DEVICE);
- kfree(rq_buf);
+ mempool_free(rq_buf, fnic->frame_recv_pool);
buf->os_buf = NULL;
}
return 0;
}
-void fnic_free_txq(struct list_head *head)
+void fnic_free_txq(struct fnic *fnic)
{
struct fnic_frame_list *cur_frame, *next;
- list_for_each_entry_safe(cur_frame, next, head, links) {
+ list_for_each_entry_safe(cur_frame, next, &fnic->tx_queue, links) {
list_del(&cur_frame->links);
- kfree(cur_frame->fp);
- kfree(cur_frame);
+ mempool_free(cur_frame->fp, fnic->frame_pool);
+ mempool_free(cur_frame, fnic->frame_elem_pool);
+ }
+}
+
+void fnic_free_rxq(struct fnic *fnic)
+{
+ struct fnic_frame_list *cur_frame, *next;
+
+ list_for_each_entry_safe(cur_frame, next, &fnic->frame_queue, links) {
+ list_del(&cur_frame->links);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
+ mempool_free(cur_frame, fnic->frame_elem_pool);
+ }
+
+ if (fnic->config.flags & VFCF_FIP_CAPABLE) {
+ list_for_each_entry_safe(cur_frame, next,
+ &fnic->fip_frame_queue, links) {
+ list_del(&cur_frame->links);
+ mempool_free(cur_frame->fp, fnic->frame_recv_pool);
+ mempool_free(cur_frame, fnic->frame_elem_pool);
+ }
}
}
dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
DMA_TO_DEVICE);
- kfree(buf->os_buf);
+ mempool_free(buf->os_buf, fnic->frame_pool);
buf->os_buf = NULL;
}
static struct kmem_cache *fnic_io_req_cache;
static struct kmem_cache *fdls_frame_cache;
static struct kmem_cache *fdls_frame_elem_cache;
+static struct kmem_cache *fdls_frame_recv_cache;
static LIST_HEAD(fnic_list);
static DEFINE_SPINLOCK(fnic_list_lock);
static DEFINE_IDA(fnic_ida);
mempool_destroy(fnic->io_req_pool);
mempool_destroy(fnic->frame_pool);
mempool_destroy(fnic->frame_elem_pool);
+ mempool_destroy(fnic->frame_recv_pool);
for (i = 0; i < FNIC_SGL_NUM_CACHES; i++)
mempool_destroy(fnic->io_sgl_pool[i]);
}
fnic->frame_elem_pool = pool;
+ pool = mempool_create_slab_pool(FDLS_MIN_FRAMES,
+ fdls_frame_recv_cache);
+ if (!pool) {
+ err = -ENOMEM;
+ goto err_out_fdls_frame_recv_pool;
+ }
+ fnic->frame_recv_pool = pool;
+
/* setup vlan config, hw inserts vlan header */
fnic->vlan_hw_insert = 1;
fnic->vlan_id = 0;
}
vnic_dev_notify_unset(fnic->vdev);
err_out_fnic_notify_set:
+ mempool_destroy(fnic->frame_recv_pool);
+err_out_fdls_frame_recv_pool:
mempool_destroy(fnic->frame_elem_pool);
err_out_fdls_frame_elem_pool:
mempool_destroy(fnic->frame_pool);
timer_delete_sync(&fnic->enode_ka_timer);
timer_delete_sync(&fnic->vn_ka_timer);
- fnic_free_txq(&fnic->fip_frame_queue);
fnic_fcoe_reset_vlans(fnic);
}
list_del(&fnic->list);
spin_unlock_irqrestore(&fnic_list_lock, flags);
- fnic_free_txq(&fnic->frame_queue);
- fnic_free_txq(&fnic->tx_queue);
+ fnic_free_rxq(fnic);
+ fnic_free_txq(fnic);
vnic_dev_notify_unset(fnic->vdev);
fnic_free_intr(fnic);
goto err_create_fdls_frame_cache_elem;
}
+ fdls_frame_recv_cache = kmem_cache_create("fdls_frame_recv",
+ FNIC_FRAME_HT_ROOM,
+ 0, SLAB_HWCACHE_ALIGN, NULL);
+ if (!fdls_frame_recv_cache) {
+ pr_err("fnic fdls frame recv cach create failed\n");
+ err = -ENOMEM;
+ goto err_create_fdls_frame_recv_cache;
+ }
+
fnic_event_queue =
alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, "fnic_event_wq");
if (!fnic_event_queue) {
if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON)
destroy_workqueue(reset_fnic_work_queue);
err_create_reset_fnic_workq:
+ kmem_cache_destroy(fdls_frame_recv_cache);
+err_create_fdls_frame_recv_cache:
destroy_workqueue(fnic_event_queue);
err_create_fnic_workq:
kmem_cache_destroy(fdls_frame_elem_cache);