2 * Copyright (c) 2009, 2010, 2011 Nicira Networks.
3 * Distributed under the terms of the GNU GPL version 2.
5 * Significant portions of this file may be copied from parts of the Linux
6 * kernel, by Linus Torvalds and others.
9 /* Interface exported by openvswitch_mod. */
15 #include <linux/kernel.h>
16 #include <linux/mutex.h>
17 #include <linux/netdevice.h>
18 #include <linux/seqlock.h>
19 #include <linux/skbuff.h>
20 #include <linux/version.h>
30 #define DP_MAX_PORTS 1024
31 #define SAMPLE_ACTION_DEPTH 3
34 * struct dp_stats_percpu - per-cpu packet processing statistics for a given
36 * @n_hit: Number of received packets for which a matching flow was found in
38 * @n_miss: Number of received packets that had no matching flow in the flow
39 * table. The sum of @n_hit and @n_miss is the number of packets that have
40 * been received by the datapath.
41 * @n_lost: Number of received packets that had no matching flow in the flow
42 * table that could not be sent to userspace (normally due to an overflow in
43 * one of the datapath's queues).
45 struct dp_stats_percpu {
53 * struct datapath - datapath for flow-based packet switching
54 * @rcu: RCU callback head for deferred destruction.
55 * @list_node: Element in global 'dps' list.
56 * @ifobj: Represents /sys/class/net/<devname>/brif. Protected by RTNL.
57 * @n_flows: Number of flows currently in flow table.
58 * @table: Current flow table. Protected by genl_lock and RCU.
59 * @ports: Map from port number to &struct vport. %OVSP_LOCAL port
60 * always exists, other ports may be %NULL. Protected by RTNL and RCU.
61 * @port_list: List of all ports in @ports in arbitrary order. RTNL required
62 * to iterate or modify.
63 * @stats_percpu: Per-CPU datapath statistics.
65 * Context: See the comment on locking at the top of datapath.c for additional
66 * locking information.
70 struct list_head list_node;
74 struct flow_table __rcu *table;
77 struct vport __rcu *ports[DP_MAX_PORTS];
78 struct list_head port_list;
81 struct dp_stats_percpu __percpu *stats_percpu;
85 * struct ovs_skb_cb - OVS data in skb CB
86 * @flow: The flow associated with this packet. May be %NULL if no flow.
87 * @tun_id: ID of the tunnel that encapsulated this packet. It is 0 if the
88 * @ip_summed: Consistently stores L4 checksumming status across different
90 * @csum_start: Stores the offset from which to start checksumming independent
91 * of the transport header on all kernel versions.
92 * packet was not received on a tunnel.
93 * @vlan_tci: Provides a substitute for the skb->vlan_tci field on kernels
99 #ifdef NEED_CSUM_NORMALIZE
100 enum csum_type ip_summed;
103 #ifdef NEED_VLAN_FIELD
107 #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
110 * struct dp_upcall - metadata to include with a packet to send to userspace
111 * @cmd: One of %OVS_PACKET_CMD_*.
112 * @key: Becomes %OVS_PACKET_ATTR_KEY. Must be nonnull.
113 * @userdata: If nonnull, its u64 value is extracted and passed to userspace as
114 * %OVS_PACKET_ATTR_USERDATA.
115 * @pid: Netlink PID to which packet should be sent. If @pid is 0 then no
116 * packet is sent and the packet is accounted in the datapath's @n_lost
119 struct dp_upcall_info {
121 const struct sw_flow_key *key;
122 const struct nlattr *userdata;
126 extern struct notifier_block dp_device_notifier;
127 extern struct genl_multicast_group dp_vport_multicast_group;
128 extern int (*dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
130 void dp_process_received_packet(struct vport *, struct sk_buff *);
131 void dp_detach_port(struct vport *);
132 int dp_upcall(struct datapath *, struct sk_buff *,
133 const struct dp_upcall_info *);
135 struct datapath *get_dp(int dp_idx);
136 const char *dp_name(const struct datapath *dp);
137 struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
140 #endif /* datapath.h */