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
115 * Allocate and initialize a new vport defined by @ops. The vport will contain
120 struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
123 struct vport *vport;
126 alloc_size = sizeof(struct vport);
132 vport = kzalloc(alloc_size, GFP_KERNEL);
133 if (!vport)
136 vport->dp = parms->dp;
137 vport->port_no = parms->port_no;
138 vport->ops = ops;
139 INIT_HLIST_NODE(&vport->dp_hash_node);
141 if (ovs_vport_set_upcall_portids(vport, parms->upcall_portids)) {
142 kfree(vport);
146 return vport;
151 * ovs_vport_free - uninitialize and free vport
153 * @vport: vport to free
155 * Frees a vport allocated with vport_alloc() when it is no longer needed.
158 * time @vport was in a datapath.
160 void ovs_vport_free(struct vport *vport)
162 /* vport is freed from RCU callback or error path, Therefore
165 kfree(rcu_dereference_raw(vport->upcall_portids));
166 kfree(vport);
182 * ovs_vport_add - add vport device (for kernel callers)
184 * @parms: Information about new vport.
186 * Creates a new vport with the specified configuration (which is dependent on
189 struct vport *ovs_vport_add(const struct vport_parms *parms)
192 struct vport *vport;
201 vport = ops->create(parms);
202 if (IS_ERR(vport)) {
204 return vport;
207 bucket = hash_bucket(ovs_dp_get_net(vport->dp),
208 ovs_vport_name(vport));
209 hlist_add_head_rcu(&vport->hash_node, bucket);
210 return vport;
218 request_module("vport-type-%d", parms->type);
228 * ovs_vport_set_options - modify existing vport device (for kernel callers)
230 * @vport: vport to modify.
236 int ovs_vport_set_options(struct vport *vport, struct nlattr *options)
238 if (!vport->ops->set_options)
240 return vport->ops->set_options(vport, options);
244 * ovs_vport_del - delete existing vport device
246 * @vport: vport to delete.
248 * Detaches @vport from its datapath and destroys it. ovs_mutex must
251 void ovs_vport_del(struct vport *vport)
253 hlist_del_rcu(&vport->hash_node);
254 module_put(vport->ops->owner);
255 vport->ops->destroy(vport);
261 * @vport: vport from which to retrieve the stats
268 void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
273 dev_stats = dev_get_stats(vport->dev, &temp);
288 * @vport: vport from which to retrieve the options.
293 * vport-specific attributes to @skb.
301 int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb)
306 if (!vport->ops->get_options)
313 err = vport->ops->get_options(vport, skb);
324 * ovs_vport_set_upcall_portids - set upcall portids of @vport.
326 * @vport: vport to modify.
329 * Sets the vport's upcall_portids to @ids.
336 int ovs_vport_set_upcall_portids(struct vport *vport, const struct nlattr *ids)
343 old = ovsl_dereference(vport->upcall_portids);
354 rcu_assign_pointer(vport->upcall_portids, vport_portids);
362 * ovs_vport_get_upcall_portids - get the upcall_portids of @vport.
364 * @vport: vport from which to retrieve the portids.
367 * Retrieves the configuration of the given vport, appending the
375 int ovs_vport_get_upcall_portids(const struct vport *vport,
380 ids = rcu_dereference_ovsl(vport->upcall_portids);
382 if (vport->dp->user_features & OVS_DP_F_VPORT_PIDS)
392 * @vport: vport from which the missed packet is received.
400 u32 ovs_vport_find_upcall_portid(const struct vport *vport,
407 ids = rcu_dereference(vport->upcall_portids);
421 * @vport: vport that received the packet
428 int ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
434 OVS_CB(skb)->input_vport = vport;
437 if (unlikely(dev_net(skb->dev) != ovs_dp_get_net(vport->dp))) {
473 void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto)
475 int mtu = vport->dev->mtu;
477 switch (vport->dev->type) {
496 if (unlikely(packet_length(skb, vport->dev) > mtu &&
499 vport->dev->name,
500 packet_length(skb, vport->dev), mtu);
501 vport->dev->stats.tx_errors++;
505 skb->dev = vport->dev;
507 vport->ops->send(skb);