aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/port.h')
-rw-r--r--net/tipc/port.h137
1 files changed, 128 insertions, 9 deletions
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 73bbf442b346..8e84b989949c 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -37,24 +37,52 @@
37#ifndef _TIPC_PORT_H 37#ifndef _TIPC_PORT_H
38#define _TIPC_PORT_H 38#define _TIPC_PORT_H
39 39
40#include "core.h"
41#include "ref.h" 40#include "ref.h"
42#include "net.h" 41#include "net.h"
43#include "msg.h" 42#include "msg.h"
44#include "dbg.h"
45#include "node_subscr.h" 43#include "node_subscr.h"
46 44
45#define TIPC_FLOW_CONTROL_WIN 512
46
47typedef void (*tipc_msg_err_event) (void *usr_handle, u32 portref,
48 struct sk_buff **buf, unsigned char const *data,
49 unsigned int size, int reason,
50 struct tipc_portid const *attmpt_destid);
51
52typedef void (*tipc_named_msg_err_event) (void *usr_handle, u32 portref,
53 struct sk_buff **buf, unsigned char const *data,
54 unsigned int size, int reason,
55 struct tipc_name_seq const *attmpt_dest);
56
57typedef void (*tipc_conn_shutdown_event) (void *usr_handle, u32 portref,
58 struct sk_buff **buf, unsigned char const *data,
59 unsigned int size, int reason);
60
61typedef void (*tipc_msg_event) (void *usr_handle, u32 portref,
62 struct sk_buff **buf, unsigned char const *data,
63 unsigned int size, unsigned int importance,
64 struct tipc_portid const *origin);
65
66typedef void (*tipc_named_msg_event) (void *usr_handle, u32 portref,
67 struct sk_buff **buf, unsigned char const *data,
68 unsigned int size, unsigned int importance,
69 struct tipc_portid const *orig,
70 struct tipc_name_seq const *dest);
71
72typedef void (*tipc_conn_msg_event) (void *usr_handle, u32 portref,
73 struct sk_buff **buf, unsigned char const *data,
74 unsigned int size);
75
76typedef void (*tipc_continue_event) (void *usr_handle, u32 portref);
77
47/** 78/**
48 * struct user_port - TIPC user port (used with native API) 79 * struct user_port - TIPC user port (used with native API)
49 * @user_ref: id of user who created user port
50 * @usr_handle: user-specified field 80 * @usr_handle: user-specified field
51 * @ref: object reference to associated TIPC port 81 * @ref: object reference to associated TIPC port
52 * <various callback routines> 82 * <various callback routines>
53 * @uport_list: adjacent user ports in list of ports held by user
54 */ 83 */
55 84
56struct user_port { 85struct user_port {
57 u32 user_ref;
58 void *usr_handle; 86 void *usr_handle;
59 u32 ref; 87 u32 ref;
60 tipc_msg_err_event err_cb; 88 tipc_msg_err_event err_cb;
@@ -64,7 +92,34 @@ struct user_port {
64 tipc_named_msg_event named_msg_cb; 92 tipc_named_msg_event named_msg_cb;
65 tipc_conn_msg_event conn_msg_cb; 93 tipc_conn_msg_event conn_msg_cb;
66 tipc_continue_event continue_event_cb; 94 tipc_continue_event continue_event_cb;
67 struct list_head uport_list; 95};
96
97/**
98 * struct tipc_port - TIPC port info available to socket API
99 * @usr_handle: pointer to additional user-defined information about port
100 * @lock: pointer to spinlock for controlling access to port
101 * @connected: non-zero if port is currently connected to a peer port
102 * @conn_type: TIPC type used when connection was established
103 * @conn_instance: TIPC instance used when connection was established
104 * @conn_unacked: number of unacknowledged messages received from peer port
105 * @published: non-zero if port has one or more associated names
106 * @congested: non-zero if cannot send because of link or port congestion
107 * @max_pkt: maximum packet size "hint" used when building messages sent by port
108 * @ref: unique reference to port in TIPC object registry
109 * @phdr: preformatted message header used when sending messages
110 */
111struct tipc_port {
112 void *usr_handle;
113 spinlock_t *lock;
114 int connected;
115 u32 conn_type;
116 u32 conn_instance;
117 u32 conn_unacked;
118 int published;
119 u32 congested;
120 u32 max_pkt;
121 u32 ref;
122 struct tipc_msg phdr;
68}; 123};
69 124
70/** 125/**
@@ -109,11 +164,76 @@ struct port {
109extern spinlock_t tipc_port_list_lock; 164extern spinlock_t tipc_port_list_lock;
110struct port_list; 165struct port_list;
111 166
167/*
168 * TIPC port manipulation routines
169 */
170struct tipc_port *tipc_createport_raw(void *usr_handle,
171 u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
172 void (*wakeup)(struct tipc_port *), const u32 importance);
173
174int tipc_reject_msg(struct sk_buff *buf, u32 err);
175
176int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);
177
178void tipc_acknowledge(u32 port_ref, u32 ack);
179
180int tipc_createport(void *usr_handle,
181 unsigned int importance, tipc_msg_err_event error_cb,
182 tipc_named_msg_err_event named_error_cb,
183 tipc_conn_shutdown_event conn_error_cb, tipc_msg_event msg_cb,
184 tipc_named_msg_event named_msg_cb,
185 tipc_conn_msg_event conn_msg_cb,
186 tipc_continue_event continue_event_cb, u32 *portref);
187
188int tipc_deleteport(u32 portref);
189
190int tipc_portimportance(u32 portref, unsigned int *importance);
191int tipc_set_portimportance(u32 portref, unsigned int importance);
192
193int tipc_portunreliable(u32 portref, unsigned int *isunreliable);
194int tipc_set_portunreliable(u32 portref, unsigned int isunreliable);
195
196int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable);
197int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable);
198
199int tipc_publish(u32 portref, unsigned int scope,
200 struct tipc_name_seq const *name_seq);
201int tipc_withdraw(u32 portref, unsigned int scope,
202 struct tipc_name_seq const *name_seq);
203
204int tipc_connect2port(u32 portref, struct tipc_portid const *port);
205
206int tipc_disconnect(u32 portref);
207
208int tipc_shutdown(u32 ref);
209
210
211/*
212 * The following routines require that the port be locked on entry
213 */
214int tipc_disconnect_port(struct tipc_port *tp_ptr);
215
216/*
217 * TIPC messaging routines
218 */
219int tipc_send(u32 portref, unsigned int num_sect, struct iovec const *msg_sect);
220
221int tipc_send2name(u32 portref, struct tipc_name const *name, u32 domain,
222 unsigned int num_sect, struct iovec const *msg_sect);
223
224int tipc_send2port(u32 portref, struct tipc_portid const *dest,
225 unsigned int num_sect, struct iovec const *msg_sect);
226
227int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest,
228 struct sk_buff *buf, unsigned int dsz);
229
230int tipc_multicast(u32 portref, struct tipc_name_seq const *seq,
231 unsigned int section_count, struct iovec const *msg);
232
112int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, 233int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
113 struct iovec const *msg_sect, u32 num_sect, 234 struct iovec const *msg_sect, u32 num_sect,
114 int err); 235 int err);
115struct sk_buff *tipc_port_get_ports(void); 236struct sk_buff *tipc_port_get_ports(void);
116struct sk_buff *port_show_stats(const void *req_tlv_area, int req_tlv_space);
117void tipc_port_recv_proto_msg(struct sk_buff *buf); 237void tipc_port_recv_proto_msg(struct sk_buff *buf);
118void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp); 238void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp);
119void tipc_port_reinit(void); 239void tipc_port_reinit(void);
@@ -138,7 +258,7 @@ static inline void tipc_port_unlock(struct port *p_ptr)
138 spin_unlock_bh(p_ptr->publ.lock); 258 spin_unlock_bh(p_ptr->publ.lock);
139} 259}
140 260
141static inline struct port* tipc_port_deref(u32 ref) 261static inline struct port *tipc_port_deref(u32 ref)
142{ 262{
143 return (struct port *)tipc_ref_deref(ref); 263 return (struct port *)tipc_ref_deref(ref);
144} 264}
@@ -196,7 +316,6 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf)
196 err = TIPC_ERR_NO_PORT; 316 err = TIPC_ERR_NO_PORT;
197 } 317 }
198reject: 318reject:
199 dbg("port->rejecting, err = %x..\n",err);
200 return tipc_reject_msg(buf, err); 319 return tipc_reject_msg(buf, err);
201} 320}
202 321