xnbo.c revision 0324f02a004039d6377111191fdd7134452d7817
/*
* 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 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Xen network backend - mac client edition.
*
*/
#include "xnb.h"
#include <sys/mac_client.h>
#include <sys/mac_provider.h>
#include <sys/mac_client_priv.h>
/* Track multicast addresses. */
typedef struct xmca {
} xmca_t;
/* State about this device instance. */
typedef struct xnbo {
char o_link_name[LIFNAMSIZ];
} xnbo_t;
static void xnbo_close_mac(xnb_t *);
/*
* Packets from the peer come here. We pass them to the mac device.
*/
static void
{
goto fail;
}
}
return;
fail:
}
/*
* Process the checksum flags `flags' provided by the peer for the
* packet `mp'.
*/
static mblk_t *
{
if ((flags & NETTXF_csum_blank) != 0) {
/*
* The checksum in the packet is blank. Determine
* whether we can do hardware offload and, if so,
* update the flags on the mblk according. If not,
* calculate and insert the checksum using software.
*/
}
return (mp);
}
/*
* Calculate the checksum flags to be relayed to the peer for the
* packet `mp'.
*/
static uint16_t
{
uint16_t r = 0;
/*
* We might also check for HCK_PARTIALCKSUM here and,
* payload, return NETRXF_data_validated.
*
* It seems that it's probably not worthwhile, as even MAC
* devices which advertise HCKSUM_INET_PARTIAL in their
* capabilities tend to use HCK_FULLCKSUM on the receive side
* - they are actually saying that in the output path the
* caller must use HCK_PARTIALCKSUM.
*
* Then again, if a NIC supports HCK_PARTIALCKSUM in its'
* output path, the host IP stack will use it. If such packets
* are destined for the peer (i.e. looped around) we would
* gain some advantage.
*/
/*
* If the MAC driver has asserted that the checksum is
* good, let the peer know.
*/
if (((pflags & HCK_FULLCKSUM) != 0) &&
(((pflags & HCK_FULLCKSUM_OK) != 0) ||
(csum == 0xffff)))
r |= NETRXF_data_validated;
return (r);
}
/*
* Packets from the mac device come here. We pass them to the peer.
*/
/*ARGSUSED*/
static void
{
}
/*
* Packets from the mac device come here. We pass them to the peer if
* address.
*/
static void
{
else \
continue;
}
continue;
}
sizeof (xnbp->xnb_mac_addr)) == 0) {
continue;
}
}
}
static boolean_t
{
int err;
const mac_info_t *mi;
struct ether_addr ea;
return (B_FALSE);
}
return (B_FALSE);
}
"device media and native media mismatch (%d != %d)",
return (B_FALSE);
}
max_sdu);
return (B_FALSE);
}
/*
* MAC_OPEN_FLAGS_MULTI_PRIMARY is relevant when we are migrating a
* guest on the localhost itself. In this case we would have the MAC
* client open for the guest being migrated *and* also for the
* migrated guest (i.e. the former will be active till the migration
* is complete when the latter will be activated). This flag states
* that it is OK for mac_unicast_add to add the primary MAC unicast
* address multiple times.
*/
MAC_OPEN_FLAGS_MULTI_PRIMARY) != 0) {
"error (%d) opening mac client", err);
return (B_FALSE);
}
if (xnbop->o_need_rx_filter)
else
xnbp);
if (err != 0) {
return (B_FALSE);
}
if (!xnbop->o_multicast_control) {
if (err != 0) {
"cannot enable promiscuous mode of %s: %d",
return (B_FALSE);
}
}
if (xnbop->o_need_setphysaddr) {
/* Warn, but continue on. */
if (err != 0) {
"cannot set MAC address of %s to "
}
}
&xnbop->o_hcksum_capab))
xnbop->o_hcksum_capab = 0;
return (B_TRUE);
}
static void
{
}
static void
{
return;
if (!locked)
if (!locked)
(char *), "close",
(void *), xnbp,
}
if (xnbop->o_promiscuous) {
}
} else {
}
}
}
}
/*
* Hotplug has completed and we are connected to the peer. We have all
* the information we need to exchange traffic, so open the MAC device
* and configure it appropriately.
*/
static boolean_t
{
}
/*
* The guest has successfully synchronize with this instance. We read
* the configuration of the guest from xenstore to check whether the
* guest requests multicast control. If not (the default) we make a
* note that the MAC device needs to be used in promiscious mode.
*/
static boolean_t
{
char *oename;
int request;
request = 0;
return (B_TRUE);
}
/*
* The guest domain has closed down the inter-domain connection. We
* close the underlying MAC device.
*/
static void
{
}
/*
* The hotplug script has completed. We read information from xenstore
* about our configuration, most notably the name of the MAC device we
* should use.
*/
static boolean_t
{
char *xsname;
int need;
"cannot read nic name from %s", xsname);
return (B_FALSE);
}
need = 0;
need = 0;
return (B_TRUE);
}
/*
* Find the multicast address `addr', return B_TRUE if it is one that
* we receive. If `remove', remove it from the set received.
*/
static boolean_t
{
if (remove) {
else
}
break;
}
}
return (B_FALSE);
if (remove) {
(char *), "remove",
(void *), xnbp,
}
return (B_TRUE);
}
/*
* Add the multicast address `addr' to the set received.
*/
static boolean_t
{
r = B_TRUE;
(char *), "add",
(void *), xnbp,
(etheraddr_t *), addr);
r = B_TRUE;
}
return (r);
}
/*
* Remove the multicast address `addr' from the set received.
*/
static boolean_t
{
boolean_t r;
return (r);
}
static int
{
static xnb_flavour_t flavour = {
};
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
(xnbp->xnb_tx_buf_count > 0)) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
nulldev, /* open */
nulldev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
nulldev, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
xnbo_attach, /* devo_attach */
xnbo_detach, /* devo_detach */
nodev, /* devo_reset */
&cb_ops, /* devo_cb_ops */
(struct bus_ops *)0, /* devo_bus_ops */
NULL, /* devo_power */
ddi_quiesce_not_needed, /* devo_quiesce */
};
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
{
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}