direct-io.hg

changeset 7773:9523e6d10511

New location for code common to both netfront and netback, with the MAC parsing
pulled here.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri Nov 11 17:59:20 2005 +0100 (2005-11-11)
parents 980967b0b161
children e2e7f47e6f79
files linux-2.6-xen-sparse/drivers/xen/Makefile linux-2.6-xen-sparse/drivers/xen/net_driver_util.c linux-2.6-xen-sparse/include/asm-xen/net_driver_util.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/Makefile	Fri Nov 11 17:56:02 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Makefile	Fri Nov 11 17:59:20 2005 +0100
     1.3 @@ -1,4 +1,5 @@
     1.4  
     1.5 +obj-y	+= net_driver_util.o
     1.6  obj-y	+= util.o
     1.7  
     1.8  obj-y	+= console/
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c	Fri Nov 11 17:59:20 2005 +0100
     2.3 @@ -0,0 +1,67 @@
     2.4 +/*****************************************************************************
     2.5 + *
     2.6 + * Utility functions for Xen network devices.
     2.7 + *
     2.8 + * Copyright (c) 2005 XenSource Ltd.
     2.9 + * 
    2.10 + * This file may be distributed separately from the Linux kernel, or
    2.11 + * incorporated into other software packages, subject to the following
    2.12 + * license:
    2.13 + * 
    2.14 + * Permission is hereby granted, free of charge, to any person obtaining a
    2.15 + * copy of this source file (the "Software"), to deal in the Software without
    2.16 + * restriction, including without limitation the rights to use, copy, modify,
    2.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    2.18 + * and to permit persons to whom the Software is furnished to do so, subject
    2.19 + * to the following conditions:
    2.20 + * 
    2.21 + * The above copyright notice and this permission notice shall be included in
    2.22 + * all copies or substantial portions of the Software.
    2.23 + * 
    2.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    2.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    2.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    2.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    2.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    2.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    2.30 + * DEALINGS IN THE SOFTWARE.
    2.31 + */
    2.32 +
    2.33 +
    2.34 +#include <linux/if_ether.h>
    2.35 +#include <linux/err.h>
    2.36 +#include <asm-xen/net_driver_util.h>
    2.37 +
    2.38 +
    2.39 +int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
    2.40 +{
    2.41 +	char *s;
    2.42 +	int i;
    2.43 +	char *e;
    2.44 +	char *macstr = xenbus_read(NULL, dev->nodename, "mac", NULL);
    2.45 +	if (IS_ERR(macstr)) {
    2.46 +		return PTR_ERR(macstr);
    2.47 +	}
    2.48 +	s = macstr;
    2.49 +	for (i = 0; i < ETH_ALEN; i++) {
    2.50 +		mac[i] = simple_strtoul(s, &e, 16);
    2.51 +		if (s == e || (e[0] != ':' && e[0] != 0)) {
    2.52 +			kfree(macstr);
    2.53 +			return -ENOENT;
    2.54 +		}
    2.55 +		s = &e[1];
    2.56 +	}
    2.57 +	kfree(macstr);
    2.58 +	return 0;
    2.59 +}
    2.60 +
    2.61 +
    2.62 +/*
    2.63 + * Local variables:
    2.64 + *  c-file-style: "linux"
    2.65 + *  indent-tabs-mode: t
    2.66 + *  c-indent-level: 8
    2.67 + *  c-basic-offset: 8
    2.68 + *  tab-width: 8
    2.69 + * End:
    2.70 + */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/net_driver_util.h	Fri Nov 11 17:59:20 2005 +0100
     3.3 @@ -0,0 +1,56 @@
     3.4 +/*****************************************************************************
     3.5 + *
     3.6 + * Utility functions for Xen network devices.
     3.7 + *
     3.8 + * Copyright (c) 2005 XenSource Ltd.
     3.9 + * 
    3.10 + * This file may be distributed separately from the Linux kernel, or
    3.11 + * incorporated into other software packages, subject to the following
    3.12 + * license:
    3.13 + * 
    3.14 + * Permission is hereby granted, free of charge, to any person obtaining a
    3.15 + * copy of this source file (the "Software"), to deal in the Software without
    3.16 + * restriction, including without limitation the rights to use, copy, modify,
    3.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    3.18 + * and to permit persons to whom the Software is furnished to do so, subject
    3.19 + * to the following conditions:
    3.20 + * 
    3.21 + * The above copyright notice and this permission notice shall be included in
    3.22 + * all copies or substantial portions of the Software.
    3.23 + * 
    3.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    3.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    3.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    3.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    3.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    3.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    3.30 + * DEALINGS IN THE SOFTWARE.
    3.31 + */
    3.32 +
    3.33 +#ifndef _ASM_XEN_NET_DRIVER_UTIL_H
    3.34 +#define _ASM_XEN_NET_DRIVER_UTIL_H
    3.35 +
    3.36 +
    3.37 +#include <asm-xen/xenbus.h>
    3.38 +
    3.39 +
    3.40 +/**
    3.41 + * Read the 'mac' node at the given device's node in the store, and parse that
    3.42 + * as colon-separated octets, placing result the given mac array.  mac must be
    3.43 + * a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
    3.44 + * Return 0 on success, or -errno on error.
    3.45 + */
    3.46 +int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
    3.47 +
    3.48 +
    3.49 +#endif /* _ASM_XEN_NET_DRIVER_UTIL_H */
    3.50 +
    3.51 +/*
    3.52 + * Local variables:
    3.53 + *  c-file-style: "linux"
    3.54 + *  indent-tabs-mode: t
    3.55 + *  c-indent-level: 8
    3.56 + *  c-basic-offset: 8
    3.57 + *  tab-width: 8
    3.58 + * End:
    3.59 + */