/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
#include <sys/bootprops.h>
#include <sys/ethernet.h>
#include <sys/ddi_implfuncs.h>
#include <sys/mac_client.h>
/*
* Debug Macros
*/
int strplumbdebug = 0;
extern ib_boot_prop_t *iscsiboot_prop;
if (strplumbdebug != 0) \
if (strplumbdebug != 0) \
if (strplumbdebug != 0) \
if (strplumbdebug != 0) \
/*
* Module linkage information for the kernel.
*/
};
&modlmisc,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
typedef struct strplumb_modspec {
char *sm_type;
char *sm_name;
{ "drv", DLD_DRIVER_NAME },
{ "drv", IP },
{ "drv", IP6 },
{ "drv", TCP },
{ "drv", TCP6 },
{ "drv", UDP },
{ "drv", UDP6 },
{ "drv", ICMP },
{ "drv", ICMP6 },
{ "drv", ARP },
{ "strmod", TIMOD }
};
/*
* Called from swapgeneric.c:loadrootmodules() in the network boot case.
*/
int
strplumb_load(void)
{
uint_t i;
DBG0("loading modules\n");
for (i = 0, p = strplumb_modlist;
i < sizeof (strplumb_modlist) / sizeof (strplumb_modlist[0]);
i++, p++) {
printf("strplumb: failed to load %s/%s\n",
return (EFAULT);
}
}
return (0);
}
static int
strplumb_init(void)
{
uint_t i;
int err;
DBG0("initializing modules\n");
for (i = 0, p = strplumb_modlist;
i < sizeof (strplumb_modlist) / sizeof (strplumb_modlist[0]);
i++, p++) {
0 : EFAULT;
else
EFAULT : 0;
if (err != 0) {
printf("strplumb: failed to initialize %s/%s\n",
return (err);
}
}
return (0);
}
/*
*/
char *ndev_name = 0;
int ndev_unit = 0;
/*
* If we booted diskless then strplumb() will have been called from
* swapgeneric.c:rootconf(). All we can do in that case is plumb the
* network device that we booted from.
*
* If we booted from a local disk, we will have been called from main(),
*/
static int
resolve_boot_path(void)
{
char *devpath;
const char *driver;
int instance;
#ifdef _OBP
#endif
else
#ifdef _OBP
/*
* OBP passes options e.g, "net:dhcp"
* remove them here
*/
#endif
/*
* Hold the devi since this is the root device.
*/
printf("strplumb: unable to hold root device: %s\n",
devpath);
return (ENXIO);
}
} else {
return (ENODEV);
printf("strplumb: cannot load ndev_name '%s'\n",
return (ENXIO);
}
}
return (0);
}
static int
{
int rval;
}
static int
{
int rval;
}
static int
{
int err;
int rval;
int af = 0;
if (iscsiboot_prop != NULL) {
}
/*
* Now set up the links. Ultimately, we should have two streams
* permanently linked under UDP. One stream consists of the
* ARP-[ifname] combination, while the other consists of IP-[ifname].
*
* We pin underneath UDP here to match what is done in ifconfig(1m);
* otherwise, ifconfig will be unable to unplumb the stream (the major
* number and mux id must both match for a successful I_PUNLINK).
*
* There are subtleties in the plumbing which make it essential to
* follow the logic used in ifconfig(1m) very closely.
*/
/*
* Plumb UDP-IP-<dev>
*/
err);
goto done;
}
&rval)) != 0) {
goto done;
}
goto done;
} else {
/*
* iscsi boot is used with ipv6 enabled
*/
}
goto done;
/* get the flags and check if ARP is needed */
printf("strplumb: getifflags %s IP failed, error %d\n",
goto done;
}
li)) != 0) {
goto done;
}
&(ifr.ifr_ip_muxid))) != 0) {
printf("strplumb: plink UDP-ARP-IP-%s failed: %d\n",
goto done;
}
/* if ARP is not needed, we are done */
goto done;
/*
* Plumb UDP-ARP-<dev>
*/
err);
goto done;
}
&rval)) != 0) {
goto done;
}
goto done;
&(ifr.ifr_arp_muxid))) != 0) {
printf("strplumb: plink UDP-ARP-%s failed: %d\n",
goto done;
}
/*
* Cache the mux ids.
*/
goto done;
}
done:
return (err);
}
/*
* Do streams plumbing for internet protocols.
*/
int
strplumb(void)
{
int err;
if ((err = strplumb_init()) != 0)
return (err);
return (err);
if ((err = resolve_boot_path()) != 0)
goto done;
goto done;
done:
return (err);
}
/* multiboot: diskless boot interface discovery */
#ifndef _OBP
static int boot_maclen;
#endif /* !_OBP */
char *
strplumb_get_netdev_path(void)
{
#ifdef _OBP
int proplen;
char *p = NULL;
return (NULL);
return (prom_bootpath());
else if (iscsiboot_prop != NULL) {
if (proplen > 0) {
if (BOP_GETPROP(bootops,
iscsi_network_path) > 0) {
if (p != NULL) {
*p = '\0';
}
return (iscsi_network_path);
}
}
}
return (NULL);
#else
/*
* hard coded ether mac len for booting floppy on
* machines with old cards
*/
if (boot_maclen != 6) {
"malformed boot_mac property, %d bytes",
}
== DDI_SUCCESS) {
/*
* These offsets are defined by dhcp standard
* Should use structure offsets
*/
} else if (iscsiboot_prop != NULL) {
} else {
return (NULL);
}
return (devpath);
#endif /* _OBP */
}
#ifndef _OBP
/*
* Get boot path from the boot_mac address
*/
/*ARGSUSED*/
static int
{
char *model_str;
/* XXX Should use "device-type" per IEEE 1275 */
return (DDI_WALK_CONTINUE);
return (DDI_WALK_CONTINUE);
}
/* We have a network device now */
return (DDI_WALK_CONTINUE);
}
ASSERT(boot_maclen != 0);
return (DDI_WALK_CONTINUE);
if (maclen != boot_maclen ||
return (DDI_WALK_CONTINUE);
}
/* found hardware with the mac address */
/* fill in dhcifname */
if (dhcack) {
}
return (DDI_WALK_TERMINATE);
}
static uchar_t *
{
char *clonepath;
"getmacaddr: ldi_ident_from_mod failed: %d\n", rc);
return (NULL);
}
if (rc) {
"getmacaddr: ldi_open_by_name(%s) failed: %d\n",
return (NULL);
}
return (NULL);
}
*maclenp = ETHERADDRL;
*maclenp != ETHERADDRL) {
*maclenp = 0;
"getmacaddr: dl_phys_addr(%s%d) failed: %d\n",
}
return (macaddr);
}
#endif /* !_OBP */