Lines Matching refs: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)
98 struct vport *vport;
100 hlist_for_each_entry_rcu(vport, bucket, hash_node,
102 if (!strcmp(name, ovs_vport_name(vport)) &&
103 net_eq(ovs_dp_get_net(vport->dp), net))
104 return vport;
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,
125 struct vport *vport;
129 alloc_size = sizeof(struct vport);
135 vport = kzalloc(alloc_size, GFP_KERNEL);
136 if (!vport)
139 vport->upcall_stats = netdev_alloc_pcpu_stats(struct vport_upcall_stats_percpu);
140 if (!vport->upcall_stats) {
145 vport->dp = parms->dp;
146 vport->port_no = parms->port_no;
147 vport->ops = ops;
148 INIT_HLIST_NODE(&vport->dp_hash_node);
150 if (ovs_vport_set_upcall_portids(vport, parms->upcall_portids)) {
155 return vport;
158 free_percpu(vport->upcall_stats);
160 kfree(vport);
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)
177 /* vport is freed from RCU callback or error path, Therefore
180 kfree(rcu_dereference_raw(vport->upcall_portids));
181 free_percpu(vport->upcall_stats);
182 kfree(vport);
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)
208 struct vport *vport;
217 vport = ops->create(parms);
218 if (IS_ERR(vport)) {
220 return vport;
223 bucket = hash_bucket(ovs_dp_get_net(vport->dp),
224 ovs_vport_name(vport));
225 hlist_add_head_rcu(&vport->hash_node, bucket);
226 return vport;
234 request_module("vport-type-%d", parms->type);
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)
254 if (!vport->ops->set_options)
256 return vport->ops->set_options(vport, 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)
269 hlist_del_rcu(&vport->hash_node);
270 module_put(vport->ops->owner);
271 vport->ops->destroy(vport);
277 * @vport: vport from which to retrieve the stats
284 void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
289 dev_stats = dev_get_stats(vport->dev, &temp);
304 * @vport: vport from which to retrieve the stats.
311 int ovs_vport_get_upcall_stats(struct vport *vport, struct sk_buff *skb)
323 stats = per_cpu_ptr(vport->upcall_stats, i);
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)
372 if (!vport->ops->get_options)
379 err = vport->ops->get_options(vport, skb);
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)
409 old = ovsl_dereference(vport->upcall_portids);
420 rcu_assign_pointer(vport->upcall_portids, vport_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,
446 ids = rcu_dereference_ovsl(vport->upcall_portids);
448 if (vport->dp->user_features & OVS_DP_F_VPORT_PIDS)
458 * @vport: vport from which the missed packet is received.
466 u32 ovs_vport_find_upcall_portid(const struct vport *vport,
473 ids = rcu_dereference(vport->upcall_portids);
487 * @vport: vport that received the packet
494 int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
500 OVS_CB(skb)->input_vport = vport;
503 if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) {
539 void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto)
541 int mtu = vport->dev->mtu;
543 switch (vport->dev->type) {
562 if (unlikely(packet_length(skb, vport->dev) > mtu &&
564 vport->dev->stats.tx_errors++;
565 if (vport->dev->flags & IFF_UP)
567 "%d > %d\n", vport->dev->name,
568 packet_length(skb, vport->dev),
573 skb->dev = vport->dev;
575 vport->ops->send(skb);