xge.c revision a23fd118e437af0a7877dd313db8fdaa3537c675
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 2002-2005 Neterion, Inc.
* All right Reserved.
*
* FileName : xge.c
*
* Description: Xge main Solaris specific initialization & routines
* for upper layer driver
*
*/
#include "xgell.h"
/* Standard Module linkage initialization for a Streams driver */
extern struct mod_ops mod_driverops;
&mod_driverops, /* Type of module. This one is a driver */
XGELL_DESC, /* short description */
&xge_ops /* driver specific ops */
};
static struct modlinkage modlinkage = {
};
/* Xge device attributes */
};
/*
* xge_event
*
* This function called by HAL to notify upper layer that some any
* event been produced.
*/
void
{
switch (item->event_type) {
if (lldev->is_initialized) {
>= XGELL_TX_LEVEL_HIGH) {
"mac_tx_update happened!");
}
}
break;
default:
break;
}
}
/*
* xgell_callback_crit_err
*
* This function called by HAL on Serious Error event. XGE_HAL_EVENT_SERR.
* Upper layer must analyze it based on %type.
*/
static void
{
(void) xgell_onerr_reset(userdata);
}
/*
* xge_queue_produce context
*/
static void
{
if (event_type == XGELL_EVENT_RESCHED_NEEDED) {
}
}
/*
* xge_driver_init_hal
*
* To initialize HAL portion of driver.
*/
static xge_hal_status_e
xge_driver_init_hal(void)
{
static xge_hal_driver_config_t driver_config;
}
/*
* _init
*
* Solaris standard _init function for a device driver
*/
int
_init(void)
{
int ret = 0;
if (status != XGE_HAL_OK) {
status);
return (EINVAL);
}
xge_hal_driver_debug_module_mask_set(0xffffffff);
"Unable to install the driver");
return (ret);
}
return (0);
}
/*
* _fini
*
* Solaris standard _fini function for device driver
*/
int
_fini(void)
{
int ret;
if (ret == 0) {
}
return (ret);
}
/*
* _info
*
* Solaris standard _info function for device driver
*/
int
{
}
/*
* xge_isr
* @arg: pointer to device private strucutre(hldev)
*
* This is the ISR scheduled by the OS to indicate to the
*/
static uint_t
{
if (!lldev->is_initialized) {
return (DDI_INTR_CLAIMED);
}
return ((status == XGE_HAL_ERR_WRONG_IRQ) ?
}
/*
* xge_configuration_init
* @device_config: pointer to xge_hal_device_config_t
*
* This function will lookup properties from .conf file to init
* the configuration data structure. If a property is not in .conf
* file, the default value should be set.
*/
static void
{
/*
* Initialize common properties
*/
/*
* We prefer HAL could provide all default values to these tunables,
* so this level could care little the configurations need by HAL.
* Leave a const here is definitely not good idea.
*/
/*
* Query PCI bus freqency from parent nexus driver.
* Note this property is only provided on SPARC platforms.
*/
dev_info, 0, "clock-frequency",
/*
* Initialize ring properties
*/
#if defined(__sparc)
#endif
} else {
}
}
1); /* HAL never provide a good named macro */
/* adaptive rx coalesing */
0);
35);
1);
16);
1);
/*
* Initialize mac properties
*/
1); /* HAL never provide a good named macro */
/*
* Initialize fifo properties
*/
#ifdef XGE_HAL_ALIGN_XMIT
#endif
#if defined(__sparc)
#endif
} else {
}
}
"fifo0_configured", 1);
/*
* Initialize tti properties
*/
/*
* Initialize errors dumping
*/
0);
0);
0);
/*
* Initialize link layer configuration
*/
}
/*
* xge_attach
* @dev_info: pointer to dev_info_t structure
* @cmd: attach command to process
*
* This is a solaris standard attach function. This
* function initializes the Xframe identified
* by the dev_info_t structure and setup the driver
* data structures corresponding to the Xframe Card.
* This function also registers the XFRAME device
* instance with the MAC Layer.
* If this function returns success then the OS
* will attach the HBA controller to this
* driver.
*/
static int
{
xgelldev_t *ll;
int ret;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
case DDI_PM_RESUME:
ret = DDI_FAILURE;
goto _exit0;
default:
ret = DDI_FAILURE;
goto _exit0;
}
/* Init device_config by lookup up properties from .conf file */
/* map BAR0 */
if (ret != DDI_SUCCESS) {
goto _exit0;
}
/* map BAR1 */
if (ret != DDI_SUCCESS) {
goto _exit1;
}
/* preallocate memory for new HAL device and private LL part */
ret = DDI_ENOMEM;
goto _exit2;
}
/* get the interrupt block cookie associated with the interrupt */
if (ret != DDI_SUCCESS) {
goto _exit2a;
}
/* Get the PCI Configuartion space handle */
if (ret != DDI_SUCCESS) {
goto _exit2a;
}
if (ret != DDI_SUCCESS) {
"%s",
"unable to allocate new LL device");
goto _exit3;
}
/* attach an interrupt handler for handling Xge device interrupts */
if (ret != DDI_SUCCESS) {
goto _exit3a;
}
/* initialize HW */
if (status != XGE_HAL_OK) {
switch (status) {
"driver is not initialized");
ret = DDI_FAILURE;
goto _exit3b;
"device is not quiescent");
goto _exit3b;
"unable to allocate memory");
ret = DDI_ENOMEM;
goto _exit3b;
default:
"can't initialize the device: %d", status);
ret = DDI_FAILURE;
goto _exit3b;
}
}
/* allocate and register Link Layer */
if (ret != DDI_SUCCESS) {
goto _exit4;
}
/* store ll as a HAL private part */
return (DDI_SUCCESS);
return (ret);
}
/*
* xge_detach
* @dev_info: pointer to dev_info_t structure
* @cmd: attach command to process
*
* This function is called by OS when the system is about
* to shutdown or when the super user tries to unload
* the driver. This function frees all the memory allocated
* during xge_attch() and also unregisters the Xframe
* device instance from the GLD framework.
*/
static int
{
switch (cmd) {
case DDI_DETACH:
break;
case DDI_PM_SUSPEND:
return (DDI_FAILURE);
default:
return (DDI_FAILURE);
}
if (lldev->is_initialized) {
"can not detach: device is not unplumbed");
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}