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

« back to all changes in this revision

Viewing changes to lib/ofp-actions.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:
1
1
/*
2
 
 * Copyright (c) 2012 Nicira, Inc.
 
2
 * Copyright (c) 2012, 2013 Nicira, Inc.
3
3
 *
4
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
5
 * you may not use this file except in compliance with the License.
70
70
    DEFINE_OFPACT(SET_L4_DST_PORT, ofpact_l4_port,       ofpact)    \
71
71
    DEFINE_OFPACT(REG_MOVE,        ofpact_reg_move,      ofpact)    \
72
72
    DEFINE_OFPACT(REG_LOAD,        ofpact_reg_load,      ofpact)    \
 
73
    DEFINE_OFPACT(STACK_PUSH,      ofpact_stack,         ofpact)    \
 
74
    DEFINE_OFPACT(STACK_POP,       ofpact_stack,         ofpact)    \
73
75
    DEFINE_OFPACT(DEC_TTL,         ofpact_cnt_ids,       cnt_ids)   \
 
76
    DEFINE_OFPACT(SET_MPLS_TTL,    ofpact_mpls_ttl,      ofpact)    \
 
77
    DEFINE_OFPACT(DEC_MPLS_TTL,    ofpact_null,          ofpact)    \
 
78
    DEFINE_OFPACT(PUSH_MPLS,       ofpact_push_mpls,     ofpact)    \
 
79
    DEFINE_OFPACT(POP_MPLS,        ofpact_pop_mpls,      ofpact)    \
74
80
                                                                    \
75
81
    /* Metadata. */                                                 \
76
82
    DEFINE_OFPACT(SET_TUNNEL,      ofpact_tunnel,        ofpact)    \
84
90
                                                                    \
85
91
    /* Arithmetic. */                                               \
86
92
    DEFINE_OFPACT(MULTIPATH,       ofpact_multipath,     ofpact)    \
87
 
    DEFINE_OFPACT(AUTOPATH,        ofpact_autopath,      ofpact)    \
88
93
                                                                    \
89
94
    /* Other. */                                                    \
90
95
    DEFINE_OFPACT(NOTE,            ofpact_note,          data)      \
91
96
    DEFINE_OFPACT(EXIT,            ofpact_null,          ofpact)    \
 
97
    DEFINE_OFPACT(SAMPLE,          ofpact_sample,        ofpact)    \
92
98
                                                                    \
93
99
    /* Instructions */                                              \
 
100
    DEFINE_OFPACT(METER,           ofpact_meter,         ofpact)    \
94
101
    /* XXX Write-Actions */                                         \
 
102
    DEFINE_OFPACT(CLEAR_ACTIONS,   ofpact_null,          ofpact)    \
95
103
    DEFINE_OFPACT(WRITE_METADATA,  ofpact_metadata,      ofpact)    \
96
 
    DEFINE_OFPACT(CLEAR_ACTIONS,   ofpact_null,          ofpact)    \
97
104
    DEFINE_OFPACT(GOTO_TABLE,      ofpact_goto_table,    ofpact)
98
105
 
99
106
/* enum ofpact_type, with a member OFPACT_<ENUM> for each action. */
192
199
 * Used for OFPAT10_OUTPUT. */
193
200
struct ofpact_output {
194
201
    struct ofpact ofpact;
195
 
    uint16_t port;              /* Output port. */
 
202
    ofp_port_t port;            /* Output port. */
196
203
    uint16_t max_len;           /* Max send len, for port OFPP_CONTROLLER. */
197
204
};
198
205
 
211
218
 * Used for OFPAT10_ENQUEUE. */
212
219
struct ofpact_enqueue {
213
220
    struct ofpact ofpact;
214
 
    uint16_t port;
 
221
    ofp_port_t port;
215
222
    uint32_t queue;
216
223
};
217
224
 
241
248
 
242
249
    /* Slaves for output. */
243
250
    unsigned int n_slaves;
244
 
    uint16_t slaves[];
 
251
    ofp_port_t slaves[];
245
252
};
246
253
 
247
254
/* OFPACT_SET_VLAN_VID.
301
308
    struct mf_subfield dst;
302
309
};
303
310
 
 
311
/* OFPACT_STACK_PUSH.
 
312
 *
 
313
 * Used for NXAST_STACK_PUSH and NXAST_STACK_POP. */
 
314
struct ofpact_stack {
 
315
    struct ofpact ofpact;
 
316
    struct mf_subfield subfield;
 
317
};
 
318
 
304
319
/* OFPACT_REG_LOAD.
305
320
 *
306
321
 * Used for NXAST_REG_LOAD, OFPAT12_SET_FIELD. */
310
325
    union mf_subvalue subvalue; /* Least-significant bits are used. */
311
326
};
312
327
 
 
328
/* OFPACT_PUSH_VLAN/MPLS/PBB
 
329
 *
 
330
 * Used for NXAST_PUSH_MPLS, OFPAT11_PUSH_MPLS. */
 
331
struct ofpact_push_mpls {
 
332
    struct ofpact ofpact;
 
333
    ovs_be16 ethertype;
 
334
};
 
335
 
 
336
/* OFPACT_POP_MPLS
 
337
 *
 
338
 * Used for NXAST_POP_MPLS, OFPAT11_POP_MPLS.. */
 
339
struct ofpact_pop_mpls {
 
340
    struct ofpact ofpact;
 
341
    ovs_be16 ethertype;
 
342
};
 
343
 
313
344
/* OFPACT_SET_TUNNEL.
314
345
 *
315
346
 * Used for NXAST_SET_TUNNEL, NXAST_SET_TUNNEL64. */
344
375
    ovs_be64 mask;
345
376
};
346
377
 
 
378
/* OFPACT_METER.
 
379
 *
 
380
 * Used for OFPIT13_METER. */
 
381
struct ofpact_meter {
 
382
    struct ofpact ofpact;
 
383
    uint32_t meter_id;
 
384
};
 
385
 
347
386
/* OFPACT_RESUBMIT.
348
387
 *
349
388
 * Used for NXAST_RESUBMIT, NXAST_RESUBMIT_TABLE. */
350
389
struct ofpact_resubmit {
351
390
    struct ofpact ofpact;
352
 
    uint16_t in_port;
 
391
    ofp_port_t in_port;
353
392
    uint8_t table_id;
354
393
};
355
394
 
356
395
/* Part of struct ofpact_learn, below. */
357
396
struct ofpact_learn_spec {
358
 
    int n_bits;
359
 
 
360
 
    int src_type;
361
 
    struct mf_subfield src;
362
 
    union mf_subvalue src_imm;
363
 
 
364
 
    int dst_type;
365
 
    struct mf_subfield dst;
 
397
    int n_bits;                 /* Number of bits in source and dest. */
 
398
 
 
399
    int src_type;               /* One of NX_LEARN_SRC_*. */
 
400
    struct mf_subfield src;     /* NX_LEARN_SRC_FIELD only. */
 
401
    union mf_subvalue src_imm;  /* NX_LEARN_SRC_IMMEDIATE only. */
 
402
 
 
403
    int dst_type;             /* One of NX_LEARN_DST_*. */
 
404
    struct mf_subfield dst;   /* NX_LEARN_DST_MATCH, NX_LEARN_DST_LOAD only. */
366
405
};
367
406
 
368
407
/* OFPACT_LEARN.
403
442
    struct mf_subfield dst;
404
443
};
405
444
 
406
 
/* OFPACT_AUTOPATH.
407
 
 *
408
 
 * Used for NXAST_AUTOPATH. */
409
 
struct ofpact_autopath {
410
 
    struct ofpact ofpact;
411
 
    struct mf_subfield dst;
412
 
    uint32_t port;
413
 
};
414
 
 
415
445
/* OFPACT_NOTE.
416
446
 *
417
447
 * Used for NXAST_NOTE. */
421
451
    uint8_t data[];
422
452
};
423
453
 
 
454
/* OFPACT_SAMPLE.
 
455
 *
 
456
 * Used for NXAST_SAMPLE. */
 
457
struct ofpact_sample {
 
458
    struct ofpact ofpact;
 
459
    uint16_t probability;  // Always >0.
 
460
    uint32_t collector_set_id;
 
461
    uint32_t obs_domain_id;
 
462
    uint32_t obs_point_id;
 
463
};
 
464
 
424
465
/* OFPACT_DEC_TTL.
425
466
 *
426
467
 * Used for OFPAT11_DEC_NW_TTL, NXAST_DEC_TTL and NXAST_DEC_TTL_CNT_IDS. */
432
473
    uint16_t cnt_ids[];
433
474
};
434
475
 
 
476
/* OFPACT_SET_MPLS_TTL.
 
477
 *
 
478
 * Used for NXAST_SET_MPLS_TTL */
 
479
struct ofpact_mpls_ttl {
 
480
    struct ofpact ofpact;
 
481
 
 
482
    uint8_t ttl;
 
483
};
 
484
 
435
485
/* OFPACT_GOTO_TABLE
436
486
 *
437
487
 * Used for OFPIT11_GOTO_TABLE */
451
501
                                                 unsigned int instructions_len,
452
502
                                                 struct ofpbuf *ofpacts);
453
503
enum ofperr ofpacts_check(const struct ofpact[], size_t ofpacts_len,
454
 
                          const struct flow *, int max_ports);
 
504
                          struct flow *, ofp_port_t max_ports,
 
505
                          uint8_t table_id);
455
506
enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len);
456
507
 
457
508
/* Converting ofpacts to OpenFlow. */
465
516
 
466
517
/* Working with ofpacts. */
467
518
bool ofpacts_output_to_port(const struct ofpact[], size_t ofpacts_len,
468
 
                            uint16_t port);
 
519
                            ofp_port_t port);
469
520
bool ofpacts_equal(const struct ofpact a[], size_t a_len,
470
521
                   const struct ofpact b[], size_t b_len);
471
522
 
531
582
    ofpact_get_##ENUM(const struct ofpact *ofpact)                      \
532
583
    {                                                                   \
533
584
        ovs_assert(ofpact->type == OFPACT_##ENUM);                      \
534
 
        return (struct STRUCT *) ofpact;                                \
 
585
        return ALIGNED_CAST(struct STRUCT *, ofpact);                   \
535
586
    }                                                                   \
536
587
                                                                        \
537
588
    static inline struct STRUCT *                                       \
559
610
 * It is enforced on parser from text string.
560
611
 */
561
612
#define OVS_INSTRUCTIONS                                    \
 
613
    DEFINE_INST(OFPIT13_METER,                              \
 
614
                ofp13_instruction_meter,          false,    \
 
615
                "meter")                                    \
 
616
                                                            \
562
617
    DEFINE_INST(OFPIT11_APPLY_ACTIONS,                      \
563
618
                ofp11_instruction_actions,        true,     \
564
619
                "apply_actions")                            \
591
646
#undef DEFINE_INST
592
647
};
593
648
 
594
 
 
595
 
static inline bool
596
 
ofpact_is_instruction(const struct ofpact *a)
597
 
{
598
 
    /* XXX Write-Actions */
599
 
    return a->type == OFPACT_CLEAR_ACTIONS
600
 
        || a->type == OFPACT_WRITE_METADATA
601
 
        || a->type == OFPACT_GOTO_TABLE;
602
 
}
603
 
 
604
 
const char *ofpact_instruction_name_from_type(enum ovs_instruction_type type);
605
 
int ofpact_instruction_type_from_name(const char *name);
 
649
const char *ovs_instruction_name_from_type(enum ovs_instruction_type type);
 
650
int ovs_instruction_type_from_name(const char *name);
 
651
enum ovs_instruction_type ovs_instruction_type_from_ofpact_type(
 
652
    enum ofpact_type);
606
653
 
607
654
void ofpact_set_field_init(struct ofpact_reg_load *load,
608
655
                           const struct mf_field *mf, const void *src);