[PATCH] s390: cio non-unique path group ids
[linux-2.6] / include / rxrpc / connection.h
1 /* connection.h: Rx connection record
2  *
3  * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11
12 #ifndef _LINUX_RXRPC_CONNECTION_H
13 #define _LINUX_RXRPC_CONNECTION_H
14
15 #include <rxrpc/types.h>
16 #include <rxrpc/krxtimod.h>
17
18 struct sk_buff;
19
20 /*****************************************************************************/
21 /*
22  * Rx connection
23  * - connections are matched by (rmt_port,rmt_addr,service_id,conn_id,clientflag)
24  * - connections only retain a refcount on the peer when they are active
25  * - connections with refcount==0 are inactive and reside in the peer's graveyard
26  */
27 struct rxrpc_connection
28 {
29         atomic_t                usage;
30         struct rxrpc_transport  *trans;         /* transport endpoint */
31         struct rxrpc_peer       *peer;          /* peer from/to which connected */
32         struct rxrpc_service    *service;       /* responsible service (inbound conns) */
33         struct rxrpc_timer      timeout;        /* decaching timer */
34         struct list_head        link;           /* link in peer's list */
35         struct list_head        proc_link;      /* link in proc list */
36         struct list_head        err_link;       /* link in ICMP error processing list */
37         struct list_head        id_link;        /* link in ID grant list */
38         struct sockaddr_in      addr;           /* remote address */
39         struct rxrpc_call       *channels[4];   /* channels (active calls) */
40         wait_queue_head_t       chanwait;       /* wait for channel to become available */
41         spinlock_t              lock;           /* access lock */
42         struct timeval          atime;          /* last access time */
43         size_t                  mtu_size;       /* MTU size for outbound messages */
44         unsigned                call_counter;   /* call ID counter */
45         rxrpc_serial_t          serial_counter; /* packet serial number counter */
46
47         /* the following should all be in net order */
48         __be32                  in_epoch;       /* peer's epoch */
49         __be32                  out_epoch;      /* my epoch */
50         __be32                  conn_id;        /* connection ID, appropriately shifted */
51         __be16                  service_id;     /* service ID */
52         uint8_t                 security_ix;    /* security ID */
53         uint8_t                 in_clientflag;  /* RXRPC_CLIENT_INITIATED if we are server */
54         uint8_t                 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */
55 };
56
57 extern int rxrpc_create_connection(struct rxrpc_transport *trans,
58                                    __be16 port,
59                                    __be32 addr,
60                                    uint16_t service_id,
61                                    void *security,
62                                    struct rxrpc_connection **_conn);
63
64 extern int rxrpc_connection_lookup(struct rxrpc_peer *peer,
65                                    struct rxrpc_message *msg,
66                                    struct rxrpc_connection **_conn);
67
68 static inline void rxrpc_get_connection(struct rxrpc_connection *conn)
69 {
70         BUG_ON(atomic_read(&conn->usage)<0);
71         atomic_inc(&conn->usage);
72         //printk("rxrpc_get_conn(%p{u=%d})\n",conn,atomic_read(&conn->usage));
73 }
74
75 extern void rxrpc_put_connection(struct rxrpc_connection *conn);
76
77 extern int rxrpc_conn_receive_call_packet(struct rxrpc_connection *conn,
78                                           struct rxrpc_call *call,
79                                           struct rxrpc_message *msg);
80
81 extern void rxrpc_conn_handle_error(struct rxrpc_connection *conn, int local, int errno);
82
83 #endif /* _LINUX_RXRPC_CONNECTION_H */