Lines Matching full:vport

21 #include "vport.h"
22 #include "vport-internal_dev.h"
31 * ovs_vport_init - initialize vport subsystem
33 * Called at module load time to initialize the vport subsystem.
46 * ovs_vport_exit - shutdown vport subsystem
48 * Called at module exit time to shutdown the vport subsystem.
95 struct vport *ovs_vport_locate(const struct net *net, const char *name) in ovs_vport_locate()
98 struct vport *vport; in ovs_vport_locate() local
100 hlist_for_each_entry_rcu(vport, bucket, hash_node, in ovs_vport_locate()
102 if (!strcmp(name, ovs_vport_name(vport)) && in ovs_vport_locate()
103 net_eq(ovs_dp_get_net(vport->dp), net)) in ovs_vport_locate()
104 return vport; in ovs_vport_locate()
110 * ovs_vport_alloc - allocate and initialize new vport
113 * @ops: vport device ops
114 * @parms: information about new vport.
116 * Allocate and initialize a new vport defined by @ops. The vport will contain
118 * vport_priv(). Some parameters of the vport will be initialized from @parms.
122 struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, in ovs_vport_alloc()
125 struct vport *vport; in ovs_vport_alloc() local
129 alloc_size = sizeof(struct vport); in ovs_vport_alloc()
135 vport = kzalloc(alloc_size, GFP_KERNEL); in ovs_vport_alloc()
136 if (!vport) in ovs_vport_alloc()
139 vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu); in ovs_vport_alloc()
140 if (!vport->upcall_stats) { in ovs_vport_alloc()
145 vport->dp = parms->dp; in ovs_vport_alloc()
146 vport->port_no = parms->port_no; in ovs_vport_alloc()
147 vport->ops = ops; in ovs_vport_alloc()
148 INIT_HLIST_NODE(&vport->dp_hash_node); in ovs_vport_alloc()
150 if (ovs_vport_set_upcall_portids(vport, parms->upcall_portids)) { in ovs_vport_alloc()
155 return vport; in ovs_vport_alloc()
158 free_percpu(vport->upcall_stats); in ovs_vport_alloc()
160 kfree(vport); in ovs_vport_alloc()
166 * ovs_vport_free - uninitialize and free vport
168 * @vport: vport to free
170 * Frees a vport allocated with vport_alloc() when it is no longer needed.
173 * time @vport was in a datapath.
175 void ovs_vport_free(struct vport *vport) in ovs_vport_free() argument
177 /* vport is freed from RCU callback or error path, Therefore in ovs_vport_free()
180 kfree(rcu_dereference_raw(vport->upcall_portids)); in ovs_vport_free()
181 free_percpu(vport->upcall_stats); in ovs_vport_free()
182 kfree(vport); in ovs_vport_free()
198 * ovs_vport_add - add vport device (for kernel callers)
200 * @parms: Information about new vport.
202 * Creates a new vport with the specified configuration (which is dependent on
205 struct vport *ovs_vport_add(const struct vport_parms *parms) in ovs_vport_add()
208 struct vport *vport; in ovs_vport_add() local
217 vport = ops->create(parms); in ovs_vport_add()
218 if (IS_ERR(vport)) { in ovs_vport_add()
220 return vport; in ovs_vport_add()
223 bucket = hash_bucket(ovs_dp_get_net(vport->dp), in ovs_vport_add()
224 ovs_vport_name(vport)); in ovs_vport_add()
225 hlist_add_head_rcu(&vport->hash_node, bucket); in ovs_vport_add()
226 return vport; in ovs_vport_add()
234 request_module("vport-type-%d", parms->type); in ovs_vport_add()
244 * ovs_vport_set_options - modify existing vport device (for kernel callers)
246 * @vport: vport to modify.
252 int ovs_vport_set_options(struct vport *vport, struct nlattr *options) in ovs_vport_set_options() argument
254 if (!vport->ops->set_options) in ovs_vport_set_options()
256 return vport->ops->set_options(vport, options); in ovs_vport_set_options()
260 * ovs_vport_del - delete existing vport device
262 * @vport: vport to delete.
264 * Detaches @vport from its datapath and destroys it. ovs_mutex must
267 void ovs_vport_del(struct vport *vport) in ovs_vport_del() argument
269 hlist_del_rcu(&vport->hash_node); in ovs_vport_del()
270 module_put(vport->ops->owner); in ovs_vport_del()
271 vport->ops->destroy(vport); in ovs_vport_del()
277 * @vport: vport from which to retrieve the stats
284 void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) in ovs_vport_get_stats() argument
289 dev_stats = dev_get_stats(vport->dev, &temp); in ovs_vport_get_stats()
304 * @vport: vport from which to retrieve the stats.
311 int ovs_vport_get_upcall_stats(struct vport *vport, struct sk_buff *skb) in ovs_vport_get_upcall_stats() argument
323 stats = per_cpu_ptr(vport->upcall_stats, i); in ovs_vport_get_upcall_stats()
354 * @vport: vport from which to retrieve the options.
359 * vport-specific attributes to @skb.
367 int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb) in ovs_vport_get_options() argument
372 if (!vport->ops->get_options) in ovs_vport_get_options()
379 err = vport->ops->get_options(vport, skb); in ovs_vport_get_options()
390 * ovs_vport_set_upcall_portids - set upcall portids of @vport.
392 * @vport: vport to modify.
395 * Sets the vport's upcall_portids to @ids.
402 int ovs_vport_set_upcall_portids(struct vport *vport, const struct nlattr *ids) in ovs_vport_set_upcall_portids() argument
409 old = ovsl_dereference(vport->upcall_portids); in ovs_vport_set_upcall_portids()
420 rcu_assign_pointer(vport->upcall_portids, vport_portids); in ovs_vport_set_upcall_portids()
428 * ovs_vport_get_upcall_portids - get the upcall_portids of @vport.
430 * @vport: vport from which to retrieve the portids.
433 * Retrieves the configuration of the given vport, appending the
441 int ovs_vport_get_upcall_portids(const struct vport *vport, in ovs_vport_get_upcall_portids() argument
446 ids = rcu_dereference_ovsl(vport->upcall_portids); in ovs_vport_get_upcall_portids()
448 if (vport->dp->user_features & OVS_DP_F_VPORT_PIDS) in ovs_vport_get_upcall_portids()
458 * @vport: vport from which the missed packet is received.
466 u32 ovs_vport_find_upcall_portid(const struct vport *vport, in ovs_vport_find_upcall_portid() argument
473 ids = rcu_dereference(vport->upcall_portids); in ovs_vport_find_upcall_portid()
487 * @vport: vport that received the packet
494 int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, in ovs_vport_receive() argument
500 OVS_CB(skb)->input_vport = vport; in ovs_vport_receive()
503 if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) { in ovs_vport_receive()
539 void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto) in ovs_vport_send() argument
541 int mtu = vport->dev->mtu; in ovs_vport_send()
543 switch (vport->dev->type) { in ovs_vport_send()
562 if (unlikely(packet_length(skb, vport->dev) > mtu && in ovs_vport_send()
564 vport->dev->stats.tx_errors++; in ovs_vport_send()
565 if (vport->dev->flags & IFF_UP) in ovs_vport_send()
567 "%d > %d\n", vport->dev->name, in ovs_vport_send()
568 packet_length(skb, vport->dev), in ovs_vport_send()
573 skb->dev = vport->dev; in ovs_vport_send()
575 vport->ops->send(skb); in ovs_vport_send()