Commit d7b71fd2 authored by James Smart's avatar James Smart Committed by Martin K. Petersen

scsi: elx: libefc: Emulex FC discovery library APIs and definitions

Add library interface definitions for:

 - SLI/Local FC port objects

 - efc_domain_s: FC domain (aka fabric) objects

 - efc_node_s: FC node (aka remote ports) objects

Link: https://lore.kernel.org/r/20210601235512.20104-10-jsmart2021@gmail.comReviewed-by: default avatarDaniel Wagner <dwagner@suse.de>
Co-developed-by: default avatarRam Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: default avatarRam Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5aa09c48
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2021 Broadcom. All Rights Reserved. The term
* “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
*/
#ifndef __EFC_H__
#define __EFC_H__
#include "../include/efc_common.h"
#include "efclib.h"
#include "efc_sm.h"
#include "efc_cmds.h"
#include "efc_domain.h"
#include "efc_nport.h"
#include "efc_node.h"
#include "efc_fabric.h"
#include "efc_device.h"
#include "efc_els.h"
#define EFC_MAX_REMOTE_NODES 2048
#define NODE_SPARAMS_SIZE 256
enum efc_scsi_del_initiator_reason {
EFC_SCSI_INITIATOR_DELETED,
EFC_SCSI_INITIATOR_MISSING,
};
enum efc_scsi_del_target_reason {
EFC_SCSI_TARGET_DELETED,
EFC_SCSI_TARGET_MISSING,
};
#define EFC_FC_ELS_DEFAULT_RETRIES 3
#define domain_sm_trace(domain) \
efc_log_debug(domain->efc, "[domain:%s] %-20s %-20s\n", \
domain->display_name, __func__, efc_sm_event_name(evt)) \
#define domain_trace(domain, fmt, ...) \
efc_log_debug(domain->efc, \
"[%s]" fmt, domain->display_name, ##__VA_ARGS__) \
#define node_sm_trace() \
efc_log_debug(node->efc, "[%s] %-20s %-20s\n", \
node->display_name, __func__, efc_sm_event_name(evt)) \
#define nport_sm_trace(nport) \
efc_log_debug(nport->efc, \
"[%s] %-20s\n", nport->display_name, efc_sm_event_name(evt)) \
#endif /* __EFC_H__ */
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 Broadcom. All Rights Reserved. The term
* “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
*/
/*
* LIBEFC LOCKING
*
* The critical sections protected by the efc's spinlock are quite broad and
* may be improved upon in the future. The libefc code and its locking doesn't
* influence the I/O path, so excessive locking doesn't impact I/O performance.
*
* The strategy is to lock whenever processing a request from user driver. This
* means that the entry points into the libefc library are protected by efc
* lock. So all the state machine transitions are protected.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include "efc.h"
int efcport_init(struct efc *efc)
{
u32 rc = 0;
spin_lock_init(&efc->lock);
INIT_LIST_HEAD(&efc->vport_list);
efc->hold_frames = false;
spin_lock_init(&efc->pend_frames_lock);
INIT_LIST_HEAD(&efc->pend_frames);
/* Create Node pool */
efc->node_pool = mempool_create_kmalloc_pool(EFC_MAX_REMOTE_NODES,
sizeof(struct efc_node));
if (!efc->node_pool) {
efc_log_err(efc, "Can't allocate node pool\n");
return -ENOMEM;
}
efc->node_dma_pool = dma_pool_create("node_dma_pool", &efc->pci->dev,
NODE_SPARAMS_SIZE, 0, 0);
if (!efc->node_dma_pool) {
efc_log_err(efc, "Can't allocate node dma pool\n");
mempool_destroy(efc->node_pool);
return -ENOMEM;
}
efc->els_io_pool = mempool_create_kmalloc_pool(EFC_ELS_IO_POOL_SZ,
sizeof(struct efc_els_io_req));
if (!efc->els_io_pool) {
efc_log_err(efc, "Can't allocate els io pool\n");
return -ENOMEM;
}
return rc;
}
static void
efc_purge_pending(struct efc *efc)
{
struct efc_hw_sequence *frame, *next;
unsigned long flags = 0;
spin_lock_irqsave(&efc->pend_frames_lock, flags);
list_for_each_entry_safe(frame, next, &efc->pend_frames, list_entry) {
list_del(&frame->list_entry);
efc->tt.hw_seq_free(efc, frame);
}
spin_unlock_irqrestore(&efc->pend_frames_lock, flags);
}
void efcport_destroy(struct efc *efc)
{
efc_purge_pending(efc);
mempool_destroy(efc->els_io_pool);
mempool_destroy(efc->node_pool);
dma_pool_destroy(efc->node_dma_pool);
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment