]> git.proxmox.com Git - mirror_ovs.git/blame - lib/worker.h
ofp-util: New function ofputil_port_to_string().
[mirror_ovs.git] / lib / worker.h
CommitLineData
70e4e586
BP
1/* Copyright (c) 2012 Nicira, Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef WORKER_H
17#define WORKER_H 1
18
19/* Worker processes.
20 *
21 * Thes functions allow an OVS daemon to fork off a "worker process" to do
22 * tasks that may unavoidably block in the kernel. The worker executes remote
23 * procedure calls on behalf of the main process.
24 *
25 * Tasks that may unavoidably block in the kernel include writes to regular
26 * files, sends to Generic Netlink sockets (which as of this writing use a
27 * global lock), and other unusual operations.
28 *
29 * The worker functions *will* block if the finite buffer between a main
30 * process and its worker process fills up.
31 */
32
33#include <stdbool.h>
34#include <stddef.h>
35#include "compiler.h"
36
37struct iovec;
38struct ofpbuf;
39
40/* The main process calls this function to start a worker. */
41void worker_start(void);
42
43/* Interface for main process to interact with the worker. */
44typedef void worker_request_func(struct ofpbuf *request,
45 const int fds[], size_t n_fds);
46typedef void worker_reply_func(struct ofpbuf *reply,
47 const int fds[], size_t n_fds, void *aux);
48
49bool worker_is_running(void);
50void worker_run(void);
51void worker_wait(void);
52
53void worker_request(const void *data, size_t size,
54 const int fds[], size_t n_fds,
55 worker_request_func *request_cb,
56 worker_reply_func *reply_cb, void *aux);
57void worker_request_iovec(const struct iovec *iovs, size_t n_iovs,
58 const int fds[], size_t n_fds,
59 worker_request_func *request_cb,
60 worker_reply_func *reply_cb, void *aux);
61
62/* Interfaces for RPC implementations (running in the worker process). */
63void worker_reply(const void *data, size_t size,
64 const int fds[], size_t n_fds);
65void worker_reply_iovec(const struct iovec *iovs, size_t n_iovs,
66 const int fds[], size_t n_fds);
67
68#endif /* worker.h */