[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / net / atm / pvc.c
blob2684a92da22bdbc3cdc98d4680c27c70fe315943
1 /* net/atm/pvc.c - ATM PVC sockets */
3 /* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
6 #include <linux/config.h>
7 #include <linux/net.h> /* struct socket, struct proto_ops */
8 #include <linux/atm.h> /* ATM stuff */
9 #include <linux/atmdev.h> /* ATM devices */
10 #include <linux/errno.h> /* error codes */
11 #include <linux/kernel.h> /* printk */
12 #include <linux/init.h>
13 #include <linux/skbuff.h>
14 #include <linux/bitops.h>
15 #include <net/sock.h> /* for sock_no_* */
17 #include "resources.h" /* devs and vccs */
18 #include "common.h" /* common for PVCs and SVCs */
21 static int pvc_shutdown(struct socket *sock,int how)
23 return 0;
27 static int pvc_bind(struct socket *sock,struct sockaddr *sockaddr,
28 int sockaddr_len)
30 struct sock *sk = sock->sk;
31 struct sockaddr_atmpvc *addr;
32 struct atm_vcc *vcc;
33 int error;
35 if (sockaddr_len != sizeof(struct sockaddr_atmpvc)) return -EINVAL;
36 addr = (struct sockaddr_atmpvc *) sockaddr;
37 if (addr->sap_family != AF_ATMPVC) return -EAFNOSUPPORT;
38 lock_sock(sk);
39 vcc = ATM_SD(sock);
40 if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) {
41 error = -EBADFD;
42 goto out;
44 if (test_bit(ATM_VF_PARTIAL,&vcc->flags)) {
45 if (vcc->vpi != ATM_VPI_UNSPEC) addr->sap_addr.vpi = vcc->vpi;
46 if (vcc->vci != ATM_VCI_UNSPEC) addr->sap_addr.vci = vcc->vci;
48 error = vcc_connect(sock, addr->sap_addr.itf, addr->sap_addr.vpi,
49 addr->sap_addr.vci);
50 out:
51 release_sock(sk);
52 return error;
56 static int pvc_connect(struct socket *sock,struct sockaddr *sockaddr,
57 int sockaddr_len,int flags)
59 return pvc_bind(sock,sockaddr,sockaddr_len);
62 static int pvc_setsockopt(struct socket *sock, int level, int optname,
63 char __user *optval, int optlen)
65 struct sock *sk = sock->sk;
66 int error;
68 lock_sock(sk);
69 error = vcc_setsockopt(sock, level, optname, optval, optlen);
70 release_sock(sk);
71 return error;
75 static int pvc_getsockopt(struct socket *sock, int level, int optname,
76 char __user *optval, int __user *optlen)
78 struct sock *sk = sock->sk;
79 int error;
81 lock_sock(sk);
82 error = vcc_getsockopt(sock, level, optname, optval, optlen);
83 release_sock(sk);
84 return error;
88 static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
89 int *sockaddr_len,int peer)
91 struct sockaddr_atmpvc *addr;
92 struct atm_vcc *vcc = ATM_SD(sock);
94 if (!vcc->dev || !test_bit(ATM_VF_ADDR,&vcc->flags)) return -ENOTCONN;
95 *sockaddr_len = sizeof(struct sockaddr_atmpvc);
96 addr = (struct sockaddr_atmpvc *) sockaddr;
97 addr->sap_family = AF_ATMPVC;
98 addr->sap_addr.itf = vcc->dev->number;
99 addr->sap_addr.vpi = vcc->vpi;
100 addr->sap_addr.vci = vcc->vci;
101 return 0;
105 static struct proto_ops pvc_proto_ops = {
106 .family = PF_ATMPVC,
107 .owner = THIS_MODULE,
109 .release = vcc_release,
110 .bind = pvc_bind,
111 .connect = pvc_connect,
112 .socketpair = sock_no_socketpair,
113 .accept = sock_no_accept,
114 .getname = pvc_getname,
115 .poll = vcc_poll,
116 .ioctl = vcc_ioctl,
117 .listen = sock_no_listen,
118 .shutdown = pvc_shutdown,
119 .setsockopt = pvc_setsockopt,
120 .getsockopt = pvc_getsockopt,
121 .sendmsg = vcc_sendmsg,
122 .recvmsg = vcc_recvmsg,
123 .mmap = sock_no_mmap,
124 .sendpage = sock_no_sendpage,
128 static int pvc_create(struct socket *sock,int protocol)
130 sock->ops = &pvc_proto_ops;
131 return vcc_create(sock, protocol, PF_ATMPVC);
135 static struct net_proto_family pvc_family_ops = {
136 .family = PF_ATMPVC,
137 .create = pvc_create,
138 .owner = THIS_MODULE,
143 * Initialize the ATM PVC protocol family
147 int __init atmpvc_init(void)
149 return sock_register(&pvc_family_ops);
152 void atmpvc_exit(void)
154 sock_unregister(PF_ATMPVC);