emlxs_mem.c revision 825277341c15b6b0d2c4b8b622ae7b1d2bdc0390
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Emulex. All rights reserved.
* Use is subject to license terms.
*/
#include <emlxs.h>
extern int32_t
{
int32_t i;
#ifdef EMLXS_SPARC
#endif /* EMLXS_SPARC */
/*
* Initialize fc_table
*/
if (cnt) {
}
/* ioatg 0 is not used, iotags 1 thru max_iotag-1 are used */
/* Allocate the fc_table */
"fc_table buffer.");
goto failed;
}
#ifdef EMLXS_SPARC
/*
* Allocate and Initialize FCP MEM_BPL table
* This is for increased performance on sparc
*/
"FCP BPL table buffer.");
goto failed;
}
/* Allocate a pool of BPLs for the FCP MEM_BPL table */
seg->fc_reserved = 0;
goto failed;
}
/* Initialize the FCP MEM_BPL table */
for (i = 0; i < seg->fc_numblks; i++) {
*fcp_bpl_table = mp;
}
}
#endif /* EMLXS_SPARC */
/* Prepare the memory pools */
for (i = 0; i < FC_MAX_SEG; i++) {
switch (i) {
case MEM_NLP:
seg->fc_reserved = 0;
seg->fc_memflag = 0;
break;
case MEM_IOCB:
seg->fc_reserved = 0;
seg->fc_memflag = 0;
break;
case MEM_MBOX:
seg->fc_reserved = 0;
seg->fc_memflag = 0;
break;
case MEM_BPL:
continue;
}
seg->fc_reserved = 0;
break;
case MEM_BUF:
/* These are the unsolicited ELS buffers. */
seg->fc_reserved = 0;
break;
case MEM_IPBUF:
/* These are the unsolicited IP buffers. */
continue;
}
seg->fc_reserved = 0;
break;
case MEM_CTBUF:
/* These are the unsolicited CT buffers. */
seg->fc_reserved = 0;
break;
case MEM_FCTBUF:
#ifdef SFCT_SUPPORT
/* These are the unsolicited FCT buffers. */
continue;
}
seg->fc_reserved = 0;
#endif /* SFCT_SUPPORT */
break;
default:
continue;
}
if (seg->fc_memsize == 0) {
continue;
}
goto failed;
}
"%s: seg=%p size=%x count=%d flags=%x base=%p",
}
return (1);
(void) emlxs_mem_free_buffer(hba);
return (0);
} /* emlxs_mem_alloc_buffer() */
/*
* emlxs_mem_free_buffer
*
* and TGTM resource.
*/
extern int
{
int32_t j;
for (j = 0; j < hba->chan_count; j++) {
/* Flush the ring */
}
/* free the mapped address match area for each ring */
for (j = 0; j < MAX_RINGS; j++) {
addr = 0;
if ((j == hba->channel_els) ||
(j == hba->channel_ct) ||
#ifdef SFCT_SUPPORT
(j == hba->CHANNEL_FCT) ||
#endif /* SFCT_SUPPORT */
(j == hba->channel_ip)) {
}
if (j == hba->channel_els) {
(void) emlxs_mem_put(hba,
} else if (j == hba->channel_ct) {
(void) emlxs_mem_put(hba,
} else if (j == hba->channel_ip) {
(void) emlxs_mem_put(hba,
}
#ifdef SFCT_SUPPORT
else if (j == hba->CHANNEL_FCT) {
(void) emlxs_mem_put(hba,
}
#endif /* SFCT_SUPPORT */
}
}
}
}
}
}
/* Free the nodes */
for (j = 0; j < MAX_VPORTS; j++) {
if (vport->node_count) {
}
}
/* Make sure the mailbox queue is empty */
/* Free memory associated with all buffers on get buffer pool */
}
#ifdef EMLXS_SPARC
}
}
#endif /* EMLXS_SPARC */
/* Free the memory segments */
for (j = 0; j < FC_MAX_SEG; j++) {
}
return (0);
} /* emlxs_mem_free_buffer() */
extern MEMSEG *
{
uint32_t i;
/* Calculate total memory size */
if (seg->fc_total_memsize == 0) {
return (NULL);
}
goto vmem_pool;
}
/* dma_pool */
for (i = 0; i < seg->fc_numblks; i++) {
goto failed;
}
/* Free the mp object */
goto failed;
}
/* Add the buffer desc to the tail of the pool freelist */
} else {
seg->fc_memget_cnt++;
}
}
return (seg);
goto failed;
}
for (i = 0; i < seg->fc_numblks; i++) {
/* Add the buffer to the tail of the pool freelist */
} else {
seg->fc_memget_cnt++;
}
}
return (seg);
return (NULL);
} /* emlxs_mem_pool_alloc() */
extern void
{
/* Save a local copy of the segment and */
/* destroy the original outside of locks */
"emlxs_mem_pool_free: %s not full. (%d < %d)",
}
/* Now free the memory */
if (seg->fc_memstart_virt) {
}
return;
}
/* Free memory associated with all buffers on get buffer pool */
}
/* Free memory associated with all buffers on put buffer pool */
}
return;
} /* emlxs_mem_pool_free() */
extern uint8_t *
{
/* Check if memory segment destroyed! */
if (seg->fc_total_memsize == 0) {
return (NULL);
}
/* Check priority and reserved status */
return (NULL);
}
}
top:
if (seg->fc_memget_ptr) {
/* Remove buffer from freelist */
seg->fc_memget_cnt = 0;
} else {
seg->fc_memget_cnt--;
}
} else {
}
} else {
if (seg->fc_memput_ptr) {
/*
* Move list from memput to memget
*/
seg->fc_memput_cnt = 0;
goto top;
}
}
return (bp);
} /* emlxs_mem_pool_get() */
extern MEMSEG *
{
/* Free the pool object */
/* Check if memory segment destroyed! */
if (seg->fc_total_memsize == 0) {
return (NULL);
}
/* Check if buffer was just freed */
return (NULL);
}
/* Validate the buffer belongs to this pool */
"emlxs_mem_pool_put: %s invalid: mp=%p " \
return (NULL);
}
} else { /* Vmem_pool */
"emlxs_mem_pool_put: %s Invalid: bp=%p base=%p " \
return (NULL);
}
}
/* Release buffer to the end of the freelist */
} else {
seg->fc_memput_cnt++;
}
return (seg);
} /* emlxs_mem_pool_put() */
extern MATCHMAP *
{
"MEM_BUF_ALLOC buffer.");
return (NULL);
}
"MEM_BUF_ALLOC DMA buffer.");
/* Free the mp object */
return (0);
}
return (mp);
} /* emlxs_mem_buf_alloc() */
extern MATCHMAP *
{
return (NULL);
}
return (mp);
} /* emlxs_mem_buf_free() */
extern uint8_t *
{
if (seg_id >= FC_MAX_SEG) {
"emlxs_mem_get: Invalid segment id = %d",
seg_id);
return (NULL);
}
/* Alloc a buffer from the pool */
if (bp) {
switch (seg_id) {
case MEM_MBOX:
break;
case MEM_IOCB:
break;
case MEM_NLP:
break;
}
}
return (bp);
} /* emlxs_mem_get() */
extern uint8_t *
{
if (seg_id >= FC_MAX_SEG) {
"emlxs_mem_put: Invalid segment id = %d: bp=%p",
return (NULL);
}
/* Verify buffer */
switch (seg_id) {
case MEM_MBOX:
return (NULL);
}
break;
case MEM_IOCB:
return (NULL);
}
/* Any IOCBQ with a packet attached did not come */
/* from our pool */
return (NULL);
}
break;
case MEM_NLP:
return (NULL);
}
break;
default:
}
return (bp);
}
return (NULL);
}
break;
}
/* Free a buffer to the pool */
return (NULL);
}
return (bp);
} /* emlxs_mem_put() */
/*
* Look up the virtual address given a mapped address
*/
/* SLI3 */
extern MATCHMAP *
{
prev = 0;
while (mp) {
if (prev == 0) {
} else {
}
}
return (mp);
}
}
"ELS Buffer not mapped: bp=%lx ringno=%x mpoff=%p mpon=%p",
prev = 0;
while (mp) {
if (prev == 0) {
} else {
}
}
return (mp);
}
}
"CT Buffer not mapped: bp=%lx ringno=%x mpoff=%p mpon=%p",
prev = 0;
while (mp) {
if (prev == 0) {
} else {
}
}
return (mp);
}
}
"IP Buffer not mapped: bp=%lx ringno=%x mpoff=%p mpon=%p",
#ifdef SFCT_SUPPORT
prev = 0;
while (mp) {
if (prev == 0) {
} else {
}
}
return (mp);
}
}
"FCT Buffer not mapped: bp=%lx ringno=%x mpoff=%p mpon=%p",
#endif /* SFCT_SUPPORT */
}
return (0);
} /* emlxs_mem_get_vaddr() */
/*
* Given a virtual address bp, generate the physical mapped address and
* place it where addr points to. Save the address pair for lookup later.
*/
/* SLI3 */
extern void
{
/*
* Update slot fc_mpon points to then bump it
* fc_mpoff is pointer head of the list.
* fc_mpon is pointer tail of the list.
*/
} else {
}
/* return mapped address */
/* return mapped address */
} else {
/* return mapped address */
}
/*
* Update slot fc_mpon points to then bump it
* fc_mpoff is pointer head of the list.
* fc_mpon is pointer tail of the list.
*/
} else {
}
/* return mapped address */
/* return mapped address */
} else {
/* return mapped address */
}
/*
* Update slot fc_mpon points to then bump it
* fc_mpoff is pointer head of the list.
* fc_mpon is pointer tail of the list.
*/
} else {
}
/* return mapped address */
} else {
}
#ifdef SFCT_SUPPORT
/*
* Update slot fc_mpon points to then bump it
* fc_mpoff is pointer head of the list.
* fc_mpon is pointer tail of the list.
*/
} else {
}
/* return mapped address */
/* return mapped address */
} else {
/* return mapped address */
}
#endif /* SFCT_SUPPORT */
}
} /* emlxs_mem_map_vaddr() */
/* SLI3 */
{
/* Get the system's page size in a DDI-compliant way. */
"Unable to alloc HBQ.");
return (ENOMEM);
}
}
return (0);
} /* emlxs_hbq_alloc() */