niu.c revision 93833965647072e8fb234b6f0cd4060544c6dc4a
/*
* 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 2008 NetXen, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/ethernet.h>
#include <sys/dditypes.h>
#include <sys/sysmacros.h>
#include "unm_inc.h"
#include "unm_nic.h"
static long phy_lock_timeout = 100000000;
{
int timeout = 0;
while (!done) {
/* acquire semaphore3 from PCI HW block */
if (done == 1)
break;
if (timeout >= phy_lock_timeout)
return (-1);
timeout++;
}
return (0);
}
static void
{
/* release semaphore3 */
}
/*
* unm_niu_gbe_phy_read - read a register from the GbE PHY via
* mii management interface.
*
* Note: The MII management interface goes through port 0.
* Individual phys are addressed as follows:
* [15:8] phy id
* [7:0] register number
*
* Returns: 0 success
* -1 error
*
*/
long
{
long timeout = 0;
long result = 0;
long restore = 0;
return (-1);
/*
* MII mgmt all goes through port 0 MAC interface, so it cannot be
* in reset
*/
&mac_cfg0, 4);
if (mac_cfg0.soft_reset) {
*(unm_crbword_t *)&temp = 0;
restore = 1;
}
*(unm_crbword_t *)&address = 0;
&address, 4);
&command, 4);
/* send read command */
&command, 4);
*(unm_crbword_t *)&status = 0;
do {
timeout++;
(timeout++ < UNM_NIU_PHY_WAITMAX));
if (timeout < UNM_NIU_PHY_WAITMAX) {
result = 0;
} else
result = -1;
if (restore)
return (result);
}
/*
* Return the current station MAC address.
* Note that the passed-in value must already be in network byte order.
*/
int
{
return (-1);
return (-1);
if (adapter->curr_window != 0) {
}
return (0);
}
/*
* Set the station MAC address.
* Note that the passed-in value must already be in network byte order.
*/
int
{
unm_crbword_t temp = 0;
return (-1);
temp <<= 16;
&temp, 4);
temp = 0;
&temp, 4);
return (0);
}
/* Enable a GbE interface */
/* ARGSUSED */
{
int zero = 0;
int one = 1;
mode_dont_care = 0;
return (-1);
}
/*
* Do NOT fail this call because the cable is unplugged.
* Updated when the link comes up...
*/
} else {
return (-1);
}
}
if (port_mode == UNM_PORT_MODE_802_3_AP) {
adapter);
adapter);
} else {
*(unm_crbword_t *)&mac_cfg0 = 0;
adapter);
*(unm_crbword_t *)&mac_cfg0 = 0;
mac_cfg0.rx_flowctl = 0;
adapter);
*(unm_crbword_t *)&mac_cfg1 = 0;
switch (adapter->link_speed) {
case MBPS_10:
case MBPS_100: /* Fall Through */
/* set mii mode */
break;
case MBPS_1000:
/* set gmii mode */
break;
default:
/* Will not happen */
break;
}
*(unm_crbword_t *)&mii_cfg = 0;
*(unm_crbword_t *)&mac_cfg0 = 0;
mac_cfg0.tx_flowctl = 0;
mac_cfg0.rx_flowctl = 0;
}
return (0);
}
/* Disable a GbE interface */
{
return (-1);
*(unm_crbword_t *)&mac_cfg0 = 0;
else
return (0);
}
/* Disable an XG interface */
{
*(unm_crbword_t *)&mac_cfg = 0;
if (port != 0)
return (-1);
&mac_cfg, 4);
} else {
return (-1);
}
return (0);
}
/* Set promiscuous mode for a GbE interface */
{
return (-1);
/* Turn off mac */
&mac_cfg, 4);
&mac_cfg, 4);
/* wait until mac is drained by sre */
/* Port 0 rx fifo bit 5 */
val);
do {
&val, 4);
cnt++;
if (cnt > 2000) {
ret = -1;
break;
}
drv_usecwait(10);
} while (val);
/* now set promiscuous mode */
if (ret != -1) {
if (mode == UNM_NIU_PROMISCOUS_MODE)
data = 0;
else
data = 1;
®, 4);
switch (port) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
ret = -1;
break;
}
®, 4);
}
/* turn the mac on back */
&mac_cfg, 4);
return (ret);
}
/*
* Set the MAC address for an XG port
* Note that the passed-in value must already be in network byte order.
*/
int
{
unm_crbword_t temp = 0;
return (-1);
switch (phy) {
case 0:
temp <<= 16;
if (port_mode == UNM_PORT_MODE_802_3_AP) {
temp = 0;
sizeof (unm_crbword_t));
} else {
temp = 0;
sizeof (unm_crbword_t));
}
break;
case 1:
temp <<= 16;
if (port_mode == UNM_PORT_MODE_802_3_AP) {
temp = 0;
sizeof (unm_crbword_t));
} else {
temp = 0;
sizeof (unm_crbword_t));
}
break;
default:
return (DDI_FAILURE);
}
return (0);
}
{
long reg;
int cnt = 0;
int result = 0;
return (-1);
if (port_mode == UNM_PORT_MODE_802_3_AP) {
reg = 0;
} else {
/* Turn off mac */
/* wait until mac is drained by sre */
/* single port case bit 9 */
reg = 0x0200;
} else {
/* Port 0 rx fifo bit 5 */
}
do {
cnt++;
if (cnt > 2000) {
result = -1;
break;
}
drv_usecwait(10);
} while (reg);
/* now set promiscuous mode */
if (result != -1) {
if (mode == UNM_NIU_PROMISCOUS_MODE) {
} else { /* FIXME use the correct mode value here */
}
}
/* turn the mac back on */
}
return (result);
}
int
{
return (-1);
if (port == 0)
else
return (0);
}
int
{
return (-1);
switch (port) {
case (0):
break;
case (1):
break;
case (2):
break;
case (3):
default:
break;
}
return (0);
}
int
{
return (-1);
®, 4);
®, 4);
return (0);
}