~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to lib/dpif.h

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
 *      location.
318
318
 *
319
319
 *    - Adding and removing ports to achieve a new configuration.
 
320
 *
 
321
 *
 
322
 * Thread-safety
 
323
 * =============
 
324
 *
 
325
 * Most of the dpif functions are fully thread-safe: they may be called from
 
326
 * any number of threads on the same or different dpif objects.  The exceptions
 
327
 * are:
 
328
 *
 
329
 *    - dpif_port_poll() and dpif_port_poll_wait() are conditionally
 
330
 *      thread-safe: they may be called from different threads only on
 
331
 *      different dpif objects.
 
332
 *
 
333
 *    - Functions that operate on struct dpif_port_dump or struct
 
334
 *      dpif_flow_dump are conditionally thread-safe with respect to those
 
335
 *      objects.  That is, one may dump ports or flows from any number of
 
336
 *      threads at once, but each thread must use its own struct dpif_port_dump
 
337
 *      or dpif_flow_dump.
320
338
 */
321
339
#ifndef DPIF_H
322
340
#define DPIF_H 1
377
395
 
378
396
const char *dpif_port_open_type(const char *datapath_type,
379
397
                                const char *port_type);
380
 
int dpif_port_add(struct dpif *, struct netdev *, uint32_t *port_nop);
381
 
int dpif_port_del(struct dpif *, uint32_t port_no);
 
398
int dpif_port_add(struct dpif *, struct netdev *, odp_port_t *port_nop);
 
399
int dpif_port_del(struct dpif *, odp_port_t port_no);
382
400
 
383
401
/* A port within a datapath.
384
402
 *
386
404
struct dpif_port {
387
405
    char *name;                 /* Network device name, e.g. "eth0". */
388
406
    char *type;                 /* Network device type, e.g. "system". */
389
 
    uint32_t port_no;           /* Port number within datapath. */
 
407
    odp_port_t port_no;         /* Port number within datapath. */
390
408
};
391
409
void dpif_port_clone(struct dpif_port *, const struct dpif_port *);
392
410
void dpif_port_destroy(struct dpif_port *);
393
411
bool dpif_port_exists(const struct dpif *dpif, const char *devname);
394
 
int dpif_port_query_by_number(const struct dpif *, uint32_t port_no,
 
412
int dpif_port_query_by_number(const struct dpif *, odp_port_t port_no,
395
413
                              struct dpif_port *);
396
414
int dpif_port_query_by_name(const struct dpif *, const char *devname,
397
415
                            struct dpif_port *);
398
 
int dpif_port_get_name(struct dpif *, uint32_t port_no,
 
416
int dpif_port_get_name(struct dpif *, odp_port_t port_no,
399
417
                       char *name, size_t name_size);
400
 
int dpif_get_max_ports(const struct dpif *);
401
 
uint32_t dpif_port_get_pid(const struct dpif *, uint32_t port_no);
 
418
odp_port_t dpif_get_max_ports(const struct dpif *);
 
419
uint32_t dpif_port_get_pid(const struct dpif *, odp_port_t port_no);
402
420
 
403
421
struct dpif_port_dump {
404
422
    const struct dpif *dpif;
447
465
int dpif_flow_flush(struct dpif *);
448
466
int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
449
467
                  const struct nlattr *key, size_t key_len,
 
468
                  const struct nlattr *mask, size_t mask_len,
450
469
                  const struct nlattr *actions, size_t actions_len,
451
470
                  struct dpif_flow_stats *);
452
471
int dpif_flow_del(struct dpif *,
464
483
void dpif_flow_dump_start(struct dpif_flow_dump *, const struct dpif *);
465
484
bool dpif_flow_dump_next(struct dpif_flow_dump *,
466
485
                         const struct nlattr **key, size_t *key_len,
 
486
                         const struct nlattr **mask, size_t *mask_len,
467
487
                         const struct nlattr **actions, size_t *actions_len,
468
488
                         const struct dpif_flow_stats **);
469
489
int dpif_flow_dump_done(struct dpif_flow_dump *);
492
512
    enum dpif_flow_put_flags flags; /* DPIF_FP_*. */
493
513
    const struct nlattr *key;       /* Flow to put. */
494
514
    size_t key_len;                 /* Length of 'key' in bytes. */
 
515
    const struct nlattr *mask;      /* Mask to put. */
 
516
    size_t mask_len;                /* Length of 'mask' in bytes. */
495
517
    const struct nlattr *actions;   /* Actions to perform on flow. */
496
518
    size_t actions_len;             /* Length of 'actions' in bytes. */
497
519
 
540
562
 
541
563
/* A packet passed up from the datapath to userspace.
542
564
 *
543
 
 * If 'key' or 'actions' is nonnull, then it points into data owned by
544
 
 * 'packet', so their memory cannot be freed separately.  (This is hardly a
545
 
 * great way to do things but it works out OK for the dpif providers and
546
 
 * clients that exist so far.)
 
565
 * If 'key', 'actions', or 'userdata' is nonnull, then it points into data
 
566
 * owned by 'packet', so their memory cannot be freed separately.  (This is
 
567
 * hardly a great way to do things but it works out OK for the dpif providers
 
568
 * and clients that exist so far.)
547
569
 */
548
570
struct dpif_upcall {
549
571
    /* All types. */
553
575
    size_t key_len;             /* Length of 'key' in bytes. */
554
576
 
555
577
    /* DPIF_UC_ACTION only. */
556
 
    uint64_t userdata;          /* Argument to OVS_ACTION_ATTR_USERSPACE. */
 
578
    struct nlattr *userdata;    /* Argument to OVS_ACTION_ATTR_USERSPACE. */
557
579
};
558
580
 
559
581
int dpif_recv_set(struct dpif *, bool enable);