summaryrefslogtreecommitdiffstats
path: root/net/ipv6/udplite.c
blob: 9cf097e206e931c6e3c184f22b8adcabedc4c03a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 *  UDPLITEv6   An implementation of the UDP-Lite protocol over IPv6.
 *              See also net/ipv4/udplite.c
 *
 *  Authors:    Gerrit Renker       <gerrit@erg.abdn.ac.uk>
 *
 *  Changes:
 *  Fixes:
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 */
#include <linux/export.h>
#include "udp_impl.h"

static int udplitev6_rcv(struct sk_buff *skb)
{
	return __udp6_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
}

static void udplitev6_err(struct sk_buff *skb,
			  struct inet6_skb_parm *opt,
			  u8 type, u8 code, int offset, __be32 info)
{
	__udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table);
}

static const struct inet6_protocol udplitev6_protocol = {
	.handler	=	udplitev6_rcv,
	.err_handler	=	udplitev6_err,
	.flags		=	INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
};

struct proto udplitev6_prot = {
	.name		   = "UDPLITEv6",
	.owner		   = THIS_MODULE,
	.close		   = udp_lib_close,
	.connect	   = ip6_datagram_connect,
	.disconnect	   = udp_disconnect,
	.ioctl		   = udp_ioctl,
	.init		   = udplite_sk_init,
	.destroy	   = udpv6_destroy_sock,
	.setsockopt	   = udpv6_setsockopt,
	.getsockopt	   = udpv6_getsockopt,
	.sendmsg	   = udpv6_sendmsg,
	.recvmsg	   = udpv6_recvmsg,
	.backlog_rcv	   = udpv6_queue_rcv_skb,
	.hash		   = udp_lib_hash,
	.unhash		   = udp_lib_unhash,
/*
 * eisa_enumerator.c - provide support for EISA adapters in PA-RISC machines
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 * Copyright (c) 2002 Daniel Engstrom <5116@telia.com>
 *
 */

#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>

#include <asm/eisa_bus.h>
#include <asm/eisa_eeprom.h>


/*
 * Todo:
 * 
 * PORT init with MASK attr and other size than byte
 * MEMORY with other decode than 20 bit
 * CRC stuff
 * FREEFORM stuff
 */

#define EPI 0xc80
#define NUM_SLOT 16
#define SLOT2PORT(x) (x<<12)


/* macros to handle unaligned accesses and 
 * byte swapping. The data in the EEPROM is
 * little-endian on the big-endian PAROSC */
#define get_8(x) (*(u_int8_t*)(x))

static inline u_int16_t get_16(const unsigned char *x)
{ 
	return (x[1] << 8) | x[0];
}

static inline u_int32_t get_32(const unsigned char *x)
{
	return (x[3] << 24) | (x[2] << 16) | (x[1] << 8) | x[0];
}

static inline u_int32_t get_24(const unsigned char *x)
{
	return (x[2] << 24) | (x[1] << 16) | (x[0] << 8);
}

static void print_eisa_id(char *s, u_int32_t id)
{
	char vendor[4];
	int rev
class="w"> id & 0xff; id >>= 8; device = id & 0xff; id >>= 8; vendor[3] = '\0'; vendor[2] = '@' + (id & 0x1f); id >>= 5; vendor[1] = '@' + (id & 0x1f); id >>= 5; vendor[0] = '@' + (id & 0x1f); id >>= 5; sprintf(s, "%s%02X%02X", vendor, device, rev); } static int configure_memory(const unsigned char *buf, struct resource *mem_parent, char *name) { int len; u_int8_t c; int i; struct resource *res; len=0; for (i=0;i<HPEE_MEMORY_MAX_ENT;i++) { c = get_8(buf+len); if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) { int result; res->name = name; res->start = mem_parent->start + get_24(buf+len+2); res->end = res->start + get_16(buf+len+5)*1024; res->flags = IORESOURCE_MEM; printk("memory %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end); result = request_resource(mem_parent, res); if (result < 0) { printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n"); return result; } } len+=7; if (!(c & HPEE_MEMORY_MORE)) { break; } } return len; } static int configure_irq(const unsigned char *buf) { int len; u_int8_t c; int i; len=0; for (i=0;i<HPEE_IRQ_MAX_ENT;i++) { c = get_8(buf+len); printk("IRQ %d ", c & HPEE_IRQ_CHANNEL_MASK); if (c & HPEE_IRQ_TRIG_LEVEL) { eisa_make_irq_level(c & HPEE_IRQ_CHANNEL_MASK); } else { eisa_make_irq_edge(c & HPEE_IRQ_CHANNEL_MASK); } len+=2; /* hpux seems to allow for * two bytes of irq data but only defines one of * them, I think */ if (!(c & HPEE_IRQ_MORE)) { break; } } return len; } static int configure_dma(const unsigned char *buf) { int len; u_int8_t c; int i; len=0; for (i=0;i<HPEE_DMA_MAX_ENT;i++) { c = get_8(buf+len); printk("DMA %d ", c&HPEE_DMA_CHANNEL_MASK); /* fixme: maybe initialize the dma channel withthe timing ? */ len+=2; if (!(c & HPEE_DMA_MORE)) { break; } } return len; } static int configure_port(const unsigned char *buf, struct resource *io_parent, char *board) { int len; u_int8_t c; int i; struct resource *res; int result; len=0; for (i=0;i<HPEE_PORT_MAX_ENT;i++) { c = get_8(buf+len); if (NULL != (res = kmalloc(sizeof(struct resource), GFP_KERNEL))) { res->name = board; res->start = get_16(buf+len+1); res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1; res->flags = IORESOURCE_IO; printk("ioports %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end); result = request_resource(io_parent, res); if (result < 0) { printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n"); return result; } } len+=3; if (!(c & HPEE_PORT_MORE)) { break; } } return len; } /* byte 1 and 2 is the port number to write * and at byte 3 the value to write starts. * I assume that there are and- and or- masks * here when HPEE_PORT_INIT_MASK is set but I have * not yet encountered this. */ static int configure_port_init(const unsigned char *buf) { int len=0; u_int8_t c; while (len<HPEE_PORT_INIT_MAX_LEN) { int s=0; c = get_8(buf+len); switch (c & HPEE_PORT_INIT_WIDTH_MASK) { case HPEE_PORT_INIT_WIDTH_BYTE: s=1; if (c & HPEE_PORT_INIT_MASK) { printk(KERN_WARNING "port_init: unverified mask attribute\n"); outb((inb(get_16(buf+len+1) & get_8(buf+len+3)) | get_8(buf+len+4)), get_16(buf+len+1)); } else { outb(get_8(buf+len+3), get_16(buf+len+1)); } break; case HPEE_PORT_INIT_WIDTH_WORD: s=2; if (c & HPEE_PORT_INIT_MASK) { printk(KERN_WARNING "