Merge "added content of grouping in of-protocol"
[openflowjava.git] / openflow-protocol-api / src / main / yang / openflow-protocol.yang
1 module openflow-protocol {
2     namespace "urn:opendaylight:openflow:protocol";
3     prefix "ofproto";
4
5
6     import ietf-inet-types {prefix inet;}
7     import ietf-yang-types {prefix yang;}
8     
9     import openflow-types {prefix oft;}
10     import openflow-extensible-match { prefix oxm;}
11     import openflow-instruction { prefix ofinstruction;}
12     import openflow-action {prefix ofaction;}
13
14
15
16     revision "2013-07-31" {
17         description "Initial model";
18     }
19
20     // Generic Structures
21
22         grouping port {
23             // reference "ofp_port";
24             leaf port-no { 
25                 // reference "ofp_port.port_no"; 
26                 type uint32;
27             }
28             leaf hw-addr { 
29                 // reference "ofp_port.hw_addr"; 
30                 type yang:mac-address;
31             }
32             leaf name { 
33                 // reference "ofp_port.name"; 
34                 type string;
35             }
36             leaf config { 
37                 // reference "ofp_port.config"; 
38                 type oft:port-config;
39             }
40             leaf state { 
41                 // reference "ofp_port.state"; 
42                 type oft:port-state;
43             }
44             leaf current-features { 
45                 description "Current features.";
46                 // reference "ofp_port.curr"; 
47                 type oft:port-features; 
48             }
49             leaf advertised-features { 
50                 description "Features being advertised by the port.";
51                 // reference "ofp_port.advertised"; 
52                 type oft:port-features; 
53             }
54             leaf supported-features { 
55                 description "Features supported by the port.";
56                 // reference "ofp_port.supported"; 
57                 type oft:port-features; 
58             }
59             leaf peer-features { 
60                 description "Features advertised by peer.";
61                 // reference "ofp_port.peer"; 
62                 type oft:port-features; 
63             }
64             leaf curr_speed { 
65                 description "Current port bitrate in kbps.";
66                 // reference "ofp_port.curr_speed"; 
67                 type uint32; 
68                 units "kbps";
69             }
70             leaf max_speed { 
71                 description "Max port bitrate in kbps";
72                 // reference "ofp_port.max_speed"; 
73                 type uint32;
74                 units "kbps"; 
75             }
76         }
77
78     // TODO: ofp_packat_queue
79
80     // # MESSAGE Structures
81         /* Immutable messages. */
82             grouping ofHeader {
83                 //reference "ofpt_header struct in Openflow Switch 1.3 Spec"
84                 leaf version {
85                     type uint8;
86                     //reference "OpenFlow Header - OFP_VERSION";
87                 }
88                 leaf xid {
89                     type uint32;
90                     //reference "OpenFlow Header - transaction id";
91                 }
92             }
93             grouping ofHelloElementHeader {
94                 //reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"
95                 leaf type {
96                     type oft:hello-element-type;
97                     //reference "OpenFlow Header element type - OFPHET_*";
98                 }
99                 leaf length {
100                     type uint16;
101                     //reference "OpenFlow Header element length";
102                 }
103             }
104             grouping hello {
105                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
106                 /* Symmetric message */
107                 uses ofHeader;
108                 
109                 list elements {
110                     uses ofHelloElementHeader;
111                     
112                     leaf data {
113                         type binary;
114                     }
115                 }
116             }
117             grouping error {
118                 // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
119                 /* Symmetric message */
120                 uses ofHeader;
121                 
122                 leaf type {
123                     type oft:error-type;
124                 }
125                 leaf code {
126                     type uint16;
127                 }
128                 leaf data {
129                     type binary; 
130                 }
131             }
132             grouping echo-request {
133                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
134                 /* Symmetric message */
135                 uses ofHeader;
136                 
137                 leaf data {
138                     type binary;
139                 }
140             }
141             grouping echo-reply {
142                 // reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"
143                 /* Symmetric message */
144                 uses ofHeader;
145                 
146                 leaf data {
147                     type binary;
148                 }
149             }
150             grouping experimenter {
151                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
152                 /* Symmetric message */
153                 uses ofHeader;
154                 
155                 leaf experimenter {
156                     type uint32;
157                 }
158                 leaf exp_type {
159                     type uint32;
160                 }
161             }
162         /* Switch configuration messages. */
163             grouping features-request {
164                 // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
165                 /* Controller/switch message */
166                 uses ofHeader;
167             }
168             grouping features-reply {
169                 // reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"
170                 /* Controller/switch message */
171                 uses ofHeader;
172                 
173                 leaf datapathId {
174                     type uint64;
175                 }
176                 leaf buffers {
177                     type uint32;
178                 }
179                 leaf tables {
180                     type uint8;
181                 }
182                 leaf auxiliaryId {
183                     type uint8;
184                 }
185                 leaf capabilities {
186                     type uint32;
187                 }
188                 leaf reserved {
189                     type uint32;
190                 }
191             }
192             grouping get-config-request {
193                 // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
194                 /* Controller/switch message */
195                 uses ofHeader;
196             }
197             grouping get-config-reply {
198                 // reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
199                 /* Controller/switch message */
200                 uses ofHeader;
201                 
202                 leaf flags {
203                     type oft:switch-config-flag;
204                 }
205                 leaf miss-send-len {
206                     type uint16;
207                 }
208             }
209             grouping set-config {
210                 // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
211                 /* Controller/switch message */
212                 
213                 uses ofHeader;
214                 
215                 leaf flags {
216                     type oft:switch-config-flag;
217                 }
218                 leaf miss-send-len {
219                     type uint16;
220                 }
221             }
222         /* Asynchronous messages. */
223             grouping packet-in {
224                 // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
225                 /* Async message */
226                 
227                 uses ofHeader;
228                 
229                 leaf buffer-id {
230                     // ID assigned by datapath.
231                     type uint32;
232                 }  
233                 leaf total-len {
234                     // Full length of frame.
235                     type uint16;
236                 }
237                 leaf reason {
238                     // Reason packet is being sent (one of OFPR_*) 
239                     type uint8;
240                 }
241                 leaf table-id {
242                     // ID of the table that was looked up
243                     type oft:table-id;
244                 }
245                 leaf cookie {
246                     // Cookie of the flow entry that was looked up.
247                     type uint64;
248                 }
249                 
250                 //TODO:: add match leaf
251                 // leaf match {
252                 //     type oft:match
253                 // }
254
255 // struct ofp_match match; /* Packet metadata. Variable size. */
256 // /* The variable size and padded match is always followed by:
257 //  *   - Exactly 2 all-zero padding bytes, then
258 //  *   - An Ethernet frame whose length is inferred from header.length.
259 //  * The padding bytes preceding the Ethernet frame ensure that the IP
260 //  * header (if any) following the Ethernet header is 32-bit aligned.
261 //  */
262                 leaf data {
263                     type binary;
264                 }
265                 
266             }
267             grouping flow-removed {
268                 // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
269                 /* Async message */
270                 uses ofHeader;
271                 
272                 leaf cookie {
273                     type uint64;
274                 }
275                 leaf priority {
276                     type uint16;
277                 }
278                 leaf reason {
279                     type oft:flow-removed-reason;
280                 }
281                 leaf table-id {
282                     type oft:table-id;
283                 }
284                 leaf duration-sec {
285                     type uint32;
286                 }
287                 leaf duration-nsec {
288                     type uint32;
289                 }
290                 leaf idle-timeout {
291                     type uint16;
292                 }
293                 leaf hard-timeout {
294                     type uint16;
295                 }
296                 leaf packet-count {
297                     type uint64;
298                 }
299                 leaf byte-count {
300                     type uint64;
301                 }
302                 //TODO:: add match leaf
303                 //leaf match {
304                 //    type oft:match;
305                 //}
306             } 
307             grouping port-status {
308                 // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
309                 
310                 uses ofHeader;
311                 
312                 uses port;
313                 
314                 leaf reason {
315                     type oft:port-reason;
316                 }
317             } /* Async message */
318         /* Controller command messages. */
319             grouping packet-out {
320                 // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
321                 /* Controller/switch message */
322                 
323                 uses ofHeader;
324                 
325                 list actions {
326                     //TODO:: replace with>> uses ofaction:action-header;
327                     uses action-header;
328                     
329                     leaf data {
330                         type binary;
331                     }
332                 }
333                 
334                 leaf buffer-id {
335                     type uint32;
336                 }
337                 leaf in-port {
338                     type oft:port-number;
339                 }
340             } 
341             grouping action-header {
342                 //TODO:: remove this grouping
343                 leaf type {
344                     type ofaction:action-type;
345                 }
346             }
347             
348             grouping flow-mod {
349                 // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
350                 /* Controller/switch message */
351                 
352                 uses ofHeader;
353                 
354                 leaf cookie {
355                     type uint64;
356                 }
357                 leaf cookie-mask {
358                     type uint64;
359                 }
360                 leaf table-id {
361                     type oft:table-id;
362                 }
363                 leaf command {
364                     type oft:flow-mod-command;
365                 }
366                 leaf idle-timeout {
367                     type uint16;
368                 }
369                 leaf hard-timeout {
370                     type uint16;
371                 }
372                 leaf priority {
373                     type uint16;
374                 }
375                 leaf buffer-id {
376                     type uint32;
377                 }
378                 leaf out-port {
379                     type oft:port-number;
380                 }
381                 leaf out-group {
382                     type uint32;
383                 }
384                 leaf flags {
385                     type uint16;
386                 }
387                 //TODO:: add match leaf
388             } 
389             grouping group-mod {
390                 // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
391                 /* Controller/switch message */
392                 
393                 uses ofHeader;
394                 
395                 leaf command {
396                     type oft:group-mod-command;
397                 }
398                 leaf type {
399                     type oft:group-type;
400                 }
401                 leaf group-id {
402                     type uint32;
403                 }
404                 
405                 list buckets {
406                     uses bucket;
407                 }
408             }
409             grouping bucket {
410                 leaf weight {
411                     type uint16;
412                 }
413                 leaf watch-port {
414                     type oft:port-number;
415                 }
416                 leaf watch-group {
417                     type uint32;
418                 }
419                 
420                 list actions {
421                     //TODO:: replace with>> uses ofaction:action-header;
422                     uses action-header;
423                 }
424             }
425             grouping port-mod {
426                 // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
427                 /* Controller/switch message */
428
429                 uses ofHeader;
430                 
431                 leaf port-no {
432                     type oft:port-number;
433                 }
434                 leaf hw-address {
435                     type yang:mac-address;
436                 }       
437                 leaf config {
438                     type oft:port-config;
439                 }   
440                 leaf mask {
441                     type oft:port-config;
442                 }  
443                 leaf advertise {
444                     type oft:port-config;
445                 }
446             } 
447             grouping table-mod {
448                 // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
449                 /* Controller/switch message */
450
451                 uses ofHeader;
452                 
453                 leaf table-id {
454                     type oft:table-id;
455                 }
456                 leaf config {
457                     type oft:port-config;
458                 }                
459             } 
460             
461         /* Multipart messages. */
462             grouping multipart-request {
463                 // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
464                 /* Controller/switch message */
465
466                 uses ofHeader;
467                 
468                 leaf type {
469                     type oft:multipart-type;
470                 }          
471                 leaf flags {
472                     type oft:multipart-request-flags;
473                 }      
474                 leaf body {
475                     type binary;
476                 }
477             } 
478             grouping multipart-reply {
479                 // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
480                 /* Controller/switch message */
481
482                 uses ofHeader;
483                 
484                 leaf type {
485                     type oft:multipart-type;
486                 }
487                 leaf flags {
488                     type oft:multipart-request-flags;
489                 }
490                 leaf body {
491                     type binary;
492                 }
493             } 
494             /* Barrier messages. */
495             grouping barrier-request {
496                 // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
497                 /* Controller/switch message */
498                 uses ofHeader;
499             } 
500             grouping barrier-reply {
501                 // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
502                 /* Controller/switch message */
503                 uses ofHeader;
504             } 
505         /* Queue Configuration messages. */
506             grouping queue-get-config-request {
507                 // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
508                 /* Controller/switch message */
509                 
510                 uses ofHeader;
511                 
512                 leaf port {
513                     type oft:port-number;
514                 }
515             } 
516             grouping queue-get-config-reply {
517                 // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
518                 /* Controller/switch message */
519
520                 uses ofHeader;
521                 
522                 leaf port {
523                     type oft:port-number;
524                 }
525                 list queues {
526                     uses packet-queue;
527                 }
528             } 
529             grouping packet-queue {
530                 leaf queue-id {
531                     type oft:queue-id;
532                 }
533                 leaf port {
534                     type oft:port-number;
535                 }
536                 list properties {
537                     uses queue-property-header;
538                 }
539             }
540             grouping queue-property-header {
541                 leaf property {
542                     type oft:queue-property;
543                 }
544             }
545             /* Controller role change request messages. */
546             grouping role-request {
547                 // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
548                 /* Controller/switch message */
549                 
550                 uses ofHeader;
551                 
552                 leaf role {
553                     type oft:controller-role;
554                 }
555                 leaf generation-id {
556                     type uint64;
557                 }
558             } 
559             grouping role-reply {
560                 // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
561                 /* Controller/switch message */
562
563                 uses ofHeader;
564                 
565                 leaf role {
566                     type oft:controller-role;
567                 }
568                 leaf generation-id {
569                     type uint64;
570                 }
571             } 
572             /* Asynchronous message configuration. */
573             grouping get-async-request {
574                 // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
575                 /* Controller/switch message */
576
577                 uses ofHeader;                
578             } 
579             grouping get-async-reply {
580                 // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
581                 /* Controller/switch message */
582
583                 uses ofHeader;
584                 
585                 list packet-in-mask {
586                     type oft:packet-in-reason;
587                 }
588                 list port-status-mask {
589                     type oft:port-reason;
590                 }
591                 list flow-removed-mask {
592                     type oft:flow-removed-reason;
593                 }
594             } 
595             grouping set-async {
596                 // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
597                 /* Controller/switch message */
598                 
599                 uses ofHeader;
600                 
601                 list packet-in-mask {
602                     type oft:packet-in-reason;
603                 }
604                 list port-status-mask {
605                     type oft:port-reason;
606                 }
607                 list flow-removed-mask {
608                     type oft:flow-removed-reason;
609                 }
610             } 
611             /* Meters and rate limiters configuration messages. */
612             grouping meter-mod {
613                 // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
614                 /* Controller/switch message */
615
616                 uses ofHeader;
617                 
618                 leaf command {
619                     type oft:meter-mod-command;
620                 } 
621                 leaf flags {
622                     type oft:meter-flags;
623                 }            
624                 leaf meter-id {
625                     type oft:meter-id;
626                 }   
627                 list bands {
628                     
629                 }
630             } 
631             
632             grouping meter-band-header {
633                 leaf type {
634                     type oft:meter-band-type;
635                 }
636                 leaf rate {
637                     type uint32;
638                 }
639                 leaf burst-size {
640                     type uint32;
641                 }
642             }
643
644
645
646                 /* Immutable messages. */
647             notification hello-message {
648                 uses hello;
649                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
650                 
651                 /* Symmetric message */
652             }
653             notification error-message {
654                 uses error;
655                 // reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"
656                 
657                 /* Symmetric message */
658             }
659             notification echo-request-message {
660                 uses echo-request;
661                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
662                 
663                 /* Symmetric message */
664             }
665             notification experimenter-message {
666                 uses experimenter;
667                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
668                 // TODO:: does switch send this when understood experimenter msg from lib?
669                 /* Symmetric message */
670             }
671     // # Notification and RPCs
672         /* Symmetric RPC. */
673             rpc echo {
674                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
675                 input {
676                     uses echo-request;
677                 }
678                 /* Controller/switch message */
679                 output {
680                     uses echo-reply;
681                 }
682             }
683             
684             rpc echo-reply {
685                 // reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"
686                 input {
687                     uses echo-reply;
688                 }
689             }
690             
691             rpc hello {
692                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"
693                 input {
694                     uses hello;
695                 }
696             }
697             
698             rpc experimenter {
699                 // reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"
700                 input {
701                     uses experimenter;
702                 }
703             }
704
705         /* Switch configuration messages. */
706             rpc get-features {
707                 // reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"
708                 input {
709                     uses features-request;
710                 }
711                 /* Controller/switch message */
712                 output {
713                     uses features-reply;
714                 }
715             }
716             
717             rpc get-config {
718                 // reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
719                 input {
720                     uses get-config-request;
721                 }
722                 output {
723                     uses get-config-reply;
724                 }
725                 /* Controller/switch message */
726             }
727             
728             rpc set-config {
729                 // reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"
730                 input {
731                     uses set-config;
732                 }   
733                 /* Controller/switch message */
734             }
735         /* Asynchronous messages. */
736             notification packet-in-message {
737                 uses packet-in;
738                 // reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"
739                 
740              /* Async message */
741             }
742             notification flow-removed-message {
743                 uses flow-removed;
744                 // reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"
745                 
746                 /* Async message */
747             } 
748             notification port-status-message {
749                 uses port-status;
750                 // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"
751                 
752             } /* Async message */
753
754         /* Controller command messages. */
755             rpc packet-out {
756                 input {
757                     uses packet-out;
758                     // reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"
759                 }
760                 /* Controller/switch message */
761             } 
762             rpc flow-mod {
763                 input {
764                     uses flow-mod;
765                     // reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"
766                 }
767                 /* Controller/switch message */
768             } 
769             rpc group-mod {
770                 input {
771                     uses group-mod;
772                     // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"
773                 }
774                 /* Controller/switch message */
775             } 
776             rpc port-mod {
777                 input {
778                     uses port-mod;
779                     // reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"
780                 }
781             } /* Controller/switch message */
782             
783             rpc table-mod {
784                 input {
785                     uses table-mod;
786                     // reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"
787                 }
788             } /* Controller/switch message */
789
790         /* Multipart messages. */
791             //FIXME: Arent this wire protocol specific?
792
793             notification multipart-request-message {
794                 uses multipart-request;
795                 // reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"
796                 
797             } /* Controller/switch message */
798             notification multipart-reply-message {
799                 uses multipart-reply;
800                 // reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"
801                 
802             } /* Controller/switch message */
803             
804
805             /* Barrier messages. */
806             rpc barrier {
807                 input {
808                     uses barrier-request;
809                     // reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"
810                 }
811                 output {
812                     uses barrier-reply;
813                     // reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"
814                 }
815             }
816         /* Queue Configuration messages. */
817             rpc get-queue-config {
818                 input {
819                     uses queue-get-config-request;
820                     // reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"
821                 }
822                 output {
823                     uses queue-get-config-reply;
824                     // reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"
825                 }
826             } 
827
828         /* Controller role change request messages. */
829             rpc role-request {
830                 input {
831                     uses role-request;
832                     // reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"
833                 }
834                 output {
835                     uses role-reply;
836                     // reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"
837                 }
838             } /* Controller/switch message */
839             
840         /* Asynchronous message configuration. */
841             notification get-async-request-message {
842                 uses get-async-request;
843                 // reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"
844                 
845             } /* Controller/switch message */
846             notification get-async-reply-message {
847                 uses get-async-reply;
848                 // reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"
849                 
850             } /* Controller/switch message */
851             notification set-async-message {
852                 uses set-async;
853                 // reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"
854                 
855             } /* Controller/switch message */
856         /* Meters and rate limiters configuration messages. */
857             rpc meter-mod {
858                 input {
859                     uses meter-mod;
860                     // reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"
861                 }
862             } /* Controller/switch message */
863 }