mac.c revision b35ccd53da4e9ec8f91c398e23ba0157c26f0822
/*
* 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"
#include <socket_impl.h>
#include <socket_inet.h>
#include <net/if_types.h>
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <sys/prom_plat.h>
#include "mac.h"
#include "mac_impl.h"
#include "atm_inet.h"
#include "ethernet_inet.h"
#include "fddi_inet.h"
#include "token_inet.h"
#include "ibd_inet.h"
/*
* MAC layer interface
*/
int arp_index; /* current arp table index */
#if !defined(__i386)
struct ofw_net_types {
char *n_name; /* OFW network media name */
int n_type; /* IFT */
} ofw_types[] = {
{ "atm", IFT_ATM },
{ "ethernet", IFT_ETHER },
{ "fddi", IFT_FDDI },
{ "token-ring", IFT_ISO88025 },
{ "ipib", IFT_IB }
};
#endif /* !__i386 */
/*
* given the mac type, initialize the mac interface state.
*/
void
mac_init(char *bootdevicename)
{
int type = 0;
#if !defined(__i386)
static char *mtu_name = "max-frame-size";
static char *chosen_net = "chosen-network-type";
static char *supported_net = "supported-network-types";
static char *netiftype = "network-interface-type";
char *wp, *media_type;
int len = 0, i;
#endif /* !__i386 */
char tmpbuf[MAXNAMELEN];
char devname[MAXNAMELEN];
if (initialized)
return;
#ifdef DEBUG
#endif /* DEBUG */
"Cannot prom_open network device %s.", bootdevicename);
}
#if !defined(__i386)
#else
#endif /* !__i386 */
#ifdef DEBUG
#endif /* DEBUG */
#if !defined(__i386)
/*
* Ask the prom for our MTU and media type. "chosen-network-type"
* is of the form of "<network type>,<speed (Mbps)>,<connector type>,
* <duplex mode>: e.g.: "ethernet,100,rj45,full"
*/
}
/*
* The following order of looking for properties is
* from FWARC 2002/345.
*/
}
media_type = NULL;
if (len > 0) {
*wp = '\0';
media_type = tmpbuf;
}
if (media_type != NULL) {
#ifdef DEBUG
#endif /* DEBUG */
for (i = 0; i < sizeof (ofw_types) /
sizeof (struct ofw_net_types); i++) {
media_type) == 0) {
break;
}
}
}
}
#else
#endif /* !__i386 */
switch (type) {
case IFT_ATM:
/*
* ATM is currently treated mostly like ethernet,
* with the exception that the MTU is most likely
* different.
*/
prom_panic("mac_init: Cannot allocate memory.");
prom_panic("mac_init: Cannot obtain MAC address.");
break;
case IFT_FDDI:
/*
* FDDI is currently treated mostly like ethernet,
* with the exception that the MTU is most likely
* different.
*/
prom_panic("mac_init: Cannot allocate memory.");
prom_panic("mac_init: Cannot obtain MAC address.");
break;
case IFT_ISO88025:
/*
* Token ring is currently treated mostly like ethernet,
* with the exception that the MTU is most likely different.
*/
prom_panic("mac_init: Cannot allocate memory.");
prom_panic("mac_init: Cannot obtain MAC address.");
break;
case IFT_IB:
ibd_init();
break;
case IFT_ETHER:
/* FALLTHRU - default to ethernet */
default:
prom_panic("mac_init: Cannot allocate memory.");
prom_panic("mac_init: Cannot obtain MAC address.");
break;
}
prom_panic("mac_init: Cannot allocate netbuf memory.");
else
}
void
mac_fini()
{
}
}
}
/* MAC layer specific socket initialization */
void
{
}
/*
* Add an entry to the ARP table. All values in table are network order.
* No checking is done to determine whether there's duplicates.
*/
void
{
arp_index++;
if (arp_index >= ARP_TABLE_SIZE)
arp_index = 0;
}
/*
* Retrieve an entry from the ARP table using network-order IP address as
* search criteria. HW address buffer is filled in up to hl in len. (make
* sure the buffer is big enough given the mac type)
*
* Returns TRUE if successful, FALSE otherwise. Will wait timeout milliseconds
* for a response.
*/
int
{
int i, result;
for (i = 0; i < ARP_TABLE_SIZE; i++) {
return (TRUE);
}
}
/* Not found. ARP for it. */
if (result) {
/* Cool - add it to the arp table */
}
return (result);
}
int
mac_get_mtu(void)
{
if (!initialized)
return (-1);
else
}
int
mac_get_dev(void)
{
if (!initialized)
return (-1);
else
}
uint8_t *
mac_get_addr_buf(void)
{
if (!initialized)
return (NULL);
else
return (mac_state.mac_addr_buf);
}
int
mac_get_addr_len(void)
{
if (!initialized)
return (-1);
else
return (mac_state.mac_addr_len);
}
int
mac_get_type(void)
{
if (!initialized)
return (-1);
else
}
void
mac_set_arp_timeout(unsigned int timeout)
{
}
int
mac_get_arp_timeout(void)
{
if (!initialized)
return (-1);
else
return (mac_state.mac_arp_timeout);
}
int
mac_get_hdr_len(void)
{
if (!initialized)
return (-1);
else
}
int
{
}
void
mac_call_rarp(void)
{
}
/*
* Map a IFT_ type to an RFC 1700 arp hwtype.
*/
{
switch (ift_type) {
case IFT_ISO88025:
break;
case IFT_ATM:
break;
case IFT_FDDI:
break;
case IFT_IB:
break;
case IFT_ETHER:
/* FALLTHRU */
default:
break;
}
return (arptype);
}