xnbo.c revision 49dbeaea2f524881d685fecf4ff04844d79b9b36
/*
* 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>
typedef struct xnbo {
} xnbo_t;
static void xnbo_close_mac(xnbo_t *);
/*
* Packets from the peer come here. We pass them to the mac device.
*/
static void
{
goto fail;
}
}
return;
fail:
}
static mblk_t *
{
if ((flags & NETTXF_csum_blank) != 0) {
/*
* It would be nice to ASSERT that xnbp->xnb_cksum_offload
* is TRUE here, but some peers insist on assuming
* that it is available even when they have been told
* otherwise.
*
* 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);
}
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.
*/
if (xnbp->xnb_cksum_offload) {
/*
* XXPV dme: Pull in improved hcksum_retrieve() from
* Crossbow, which gives back the csum in the seventh
* argument for HCK_FULLCKSUM.
*/
/*
* 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.
*/
/*ARGSUSED*/
static void
{
else \
continue;
}
continue;
}
sizeof (xnbp->xnb_mac_addr)) == 0) {
continue;
}
}
}
static boolean_t
{
const mac_info_t *mi;
char *xsname;
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_USE_DATALINK_NAME) != 0) {
"error (%d) opening mac client", err);
return (B_FALSE);
}
if (err != 0) {
"failed to get the primary MAC address of "
return (B_FALSE);
}
/*
* Should the receive path filter packets from the downstream
* NIC before passing them to the peer? The default is "no".
*/
need_rx_filter = 0;
if (need_rx_filter > 0)
else
/*
* Should we set the underlying NIC into promiscuous mode? The
* default is "no".
*/
need_promiscuous = 0;
if (need_promiscuous == 0) {
} else {
if (err != 0) {
"cannot enable promiscuous mode of %s: %d",
return (B_FALSE);
}
}
&xnbop->o_hcksum_capab))
xnbop->o_hcksum_capab = 0;
/*
* Should we set the physical address of the underlying NIC
* to match that assigned to the peer? The default is "no".
*/
need_setphysaddr = 0;
if (need_setphysaddr > 0) {
/* Warn, but continue on. */
if (err != 0) {
"cannot set MAC address of %s to "
}
}
return (B_TRUE);
}
/*
* xnb calls back here when the user-level hotplug code reports that
* the hotplug has successfully completed. For this flavour that means
* that the underlying MAC device that we will use is ready to be
* opened.
*/
static boolean_t
{
char *xsname;
"cannot read nic name from %s", xsname);
return (B_FALSE);
}
}
static void
{
return;
}
if (xnbop->o_promiscuous) {
}
} else {
}
}
}
}
/*
* xnb calls back here when we successfully synchronize with the
* driver in the guest domain. In this flavour there is nothing to do as
* we open the underlying MAC device on successful hotplug completion.
*/
/*ARGSUSED*/
static void
{
}
/*
* xnb calls back here when the driver in the guest domain has closed
* down the inter-domain connection. We close the underlying MAC device.
*/
static void
{
}
static int
{
static xnb_flavour_t flavour = {
};
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
xnbop->o_hcksum_capab = 0;
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));
}