Solved Bug 6302-
[packetcable.git] / packetcable-policy-model / src / main / yang / packetcable.yang
1 module packetcable
2 {
3     namespace "urn:packetcable";
4     prefix "pcmm";
5
6     import ietf-yang-types     { prefix yang;  revision-date "2013-07-15"; }
7     import ietf-inet-types     { prefix inet; revision-date "2013-07-15"; }
8     import yang-ext { prefix ext; revision-date "2013-07-09"; }
9
10     description "This module contains the PCMM Converged Cable Access Platform (CCAP) definitions";
11     organization "OpenDaylight Project";
12
13     revision 2016-11-07 {
14         description "Added priority field to all classifiers";
15     }
16     revision 2016-10-17 {
17         description "Modified service-flow-direction values to match the PCMM Spec";
18     }
19     revision 2015-11-01 {
20         description "Extended gates to support multiple classifiers.";
21     }
22     revision 2015-10-26 {
23         description "Corrected pluralization of containers/lists and added containers around lists where needed";
24     }
25     revision 2015-03-27 {
26         description "Initial revision of PCMM CCAP definitions";
27     }
28
29
30     // Global typedefs
31     typedef service-class-name {
32         type string { length "2..16"; }
33         description "The Service Class Name is MUST be 2-16 bytes.";
34     }
35     typedef service-flow-direction {
36         type enumeration {
37               enum ds {
38                 value "0";
39                 description "Downstream service flow.";
40               }
41               enum us {
42                 value "1";
43                 description "Upstream service flow.";
44               }
45           }
46         description "This value represents the service flow direction.";
47       }
48      typedef tp-protocol {
49          type uint16 {range "0..257";}
50         description "This value represents the IP transport protocol (or Next Header) where 256 is any protocol and 257 is TCP or UDP";
51      }
52      typedef tos-byte {
53          type uint8;
54          description "TOS/TC byte or mask";
55      }
56
57     identity ccap-context {
58         description "Identity used to mark ccap context";
59     }
60
61     identity app-context {
62         description "Identity used to mark app context";
63     }
64
65     // CCAP devices
66     container ccaps {
67         list ccap {
68             description "
69                 CCAP devices are known by their network name which is any string.
70                 Each CCAP device has a network address:port, a list of subscriber IP subnets,
71                 and a list of available Service Class Names.
72                 ";
73             key "ccapId";
74             ext:context-instance "ccap-context";
75             leaf ccapId {
76                 type string;
77                 description "CCAP Identity";
78                 mandatory true;
79             }
80             uses ccap-attributes;
81         }
82     }
83
84     grouping ccap-connection {
85          leaf ipAddress {
86                type inet:ip-address;
87                description "IP Address of CCAP";
88                mandatory true;
89            }
90            leaf port {
91                type inet:port-number;
92             description "COPS session TCP port number";
93              default 3918;
94         }
95         leaf connected {
96             config false;
97             type boolean;
98             description "COPS session state";
99             mandatory true;
100         }
101         leaf-list error {
102             config false;
103             type string;
104             description "Operational errors";
105         }
106 //        leaf idle-detect {
107 //            type uint8;
108 //            description "COPS connection idle timer (seconds)";
109 //          mandatory true;
110 //        }
111 //        leaf isIdle {
112 //            config false;
113 //            type boolean;
114 //            description "COPS connection idle state";
115 //          mandatory true;
116 //        }
117
118         leaf timestamp {
119             config false;
120             type yang:date-and-time;
121             description "Last update timestamp";
122             mandatory true;
123         }
124     }
125
126     grouping ccap-attributes {
127         description "
128             Each CCAP device has a COPS connection address:port,
129             a list of subscriber IP subnets, and
130             a list of available Service Class Names.
131             ";
132         container connection {
133             uses ccap-connection;
134         }
135         container amId {
136             leaf am-tag {
137                 type uint16;
138                 description "Application Manager Tag -- unique for this operator";
139                 mandatory true;
140             }
141             leaf am-type {
142                  type uint16;
143                 description "Application Manager Type -- unique for this AM tag";
144                 mandatory true;
145             }
146         }
147         leaf-list subscriber-subnets {
148             type inet:ip-prefix;
149         }
150         leaf-list upstream-scns {
151             type service-class-name;
152         }
153         leaf-list downstream-scns {
154             type service-class-name;
155         }
156         leaf-list error {
157             config false;
158             type string;
159             description "ccap data errors";
160         }
161     }
162
163     // PCMM QoS Gates
164     container qos {
165         description "
166             PCMM QoS Gates are organized as a tree by Application/Subscriber/Gate:
167                 Each Application is known by its appId which is any string.
168                 Each Subscriber is known by its subscriberId which is a CPE IP address in either IPv4 or IPv6 format.
169                 Each Gate is known by its gateId which is any string.
170
171             The subscriber's CPE IP address is used to locate the CCAP device that is currently hosting the
172             the Cable Modem that is connected to the subscriber's device. Therefore, it is not necessary
173             for the PCMM applications to know the topology of the CCAP devices and CMs in the network path
174             to their subscriber devices.
175
176             Note that each CCAP entry contains a list of connected subscriber IP subnets as well as a list
177             of all Service Class Names (SCNs) available on the CCAP device.
178             ";
179         uses pcmm-qos-gates;
180     }
181
182     grouping pcmm-qos-gates {
183         container apps {
184             list app {
185                 key "appId";
186                 ext:context-instance "app-context";
187                 leaf appId {
188                     type string;
189                     description "Application Identity";
190                 }
191                 container subscribers {
192                     list subscriber {
193                         key "subscriberId";
194                         leaf subscriberId {
195                             type string;
196                             description "Subscriber Identity -- must be a CM or CPE IP address";
197                             mandatory true;
198                         }
199                         container gates {
200                             list gate {
201                                 key "gateId";
202                                 leaf gateId {
203                                     type string;
204                                     description "Qos Gate Identity";
205                                     mandatory true;
206                                 }
207                                 uses gate-operational-attributes;
208                                 uses pcmm-qos-gate-attributes;
209                             }
210                         }
211                     }
212                 }
213             }
214         }
215     }
216
217     grouping gate-operational-attributes {
218                 leaf gatePath {
219                         config false;
220                     type string;
221                     description "FQ Gate path app/subscriber/gate";
222                     mandatory true;
223                 }
224                 leaf ccapId {
225                         config false;
226                     type string;
227                     description "CCAP Identity";
228                     mandatory true;
229                 }
230                 leaf cops-gate-state {
231                         config false;
232                         type string;
233                         description "Operational COPS Gate state";
234                         mandatory true;
235                 }
236                 leaf cops-gate-time-info {
237                         config false;
238                         type string;
239                         description "Operational COPS Gate time info";
240                         mandatory true;
241                 }
242                 leaf cops-gate-usage-info {
243           config false;
244           type string;
245           description "Operational COPS gate usage info";
246           mandatory true;
247         }
248         leaf cops-gateId {
249             config false;
250             type string;
251             description "Gate operational COPS Id";
252             mandatory true;
253         }
254         leaf-list error {
255             config false;
256             type string;
257             description "Gate operational error";
258         }
259         leaf timestamp {
260             config false;
261             type yang:date-and-time;
262             description "Gate operational attributes timestamp";
263             mandatory true;
264         }
265     }
266
267
268     grouping classifier-attributes {
269         container classifiers {
270             list classifier-container {
271                 key "classifier-id";
272                 leaf classifier-id {
273                     type uint8;
274                     description "Classifier ID and Gate classifier priority";
275                 }
276                    choice classifier-choice {
277                       case qos-classifier-choice {
278                         uses pcmm-qos-classifier;
279                     }
280                     case ext-classifier-choice {
281                         uses pcmm-qos-ext-classifier;
282                      }
283                      case ipv6-classifier-choice {
284                          uses pcmm-qos-ipv6-classifier;
285                      }
286                  }
287              }
288         }
289     }
290
291     grouping pcmm-qos-gate-attributes {
292          uses pcmm-qos-gate-spec;
293          uses pcmm-qos-traffic-profile;
294          uses classifier-attributes;
295     }
296
297     grouping pcmm-qos-gate-spec {
298         container gate-spec {
299             leaf direction {
300                 type service-flow-direction;
301                 description "Gate Direction (ignored for traffic profile SCN)";
302             }
303             leaf dscp-tos-overwrite {
304                 type tos-byte;
305                 description "Optional DSCP/TOS overwrite value";
306             }
307             leaf dscp-tos-mask {
308                 type tos-byte;
309                 description "Optional DSCP/TOS overwrite AND mask";
310             }
311         }
312     }
313
314     grouping pcmm-qos-traffic-profile {
315         container traffic-profile {
316             leaf service-class-name {
317                 type service-class-name;
318                 description "The Service Class Name (SCN). This SCN must be pre-provisioned on the target CCAP";
319                 mandatory true;
320             }
321         }
322     }
323
324     grouping tp-port-match-ranges {
325         leaf srcPort-start {
326             type inet:port-number;
327             description "TCP/UDP source port range start.";
328         }
329         leaf srcPort-end {
330             type inet:port-number;
331             description "TCP/UDP source port range end.";
332         }
333         leaf dstPort-start {
334             type inet:port-number;
335             description "TCP/UDP destination port range start.";
336         }
337         leaf dstPort-end {
338             type inet:port-number;
339             description "TCP/UDP destination port range end.";
340         }
341     }
342
343     grouping pcmm-qos-classifier {
344         container classifier {
345             leaf srcIp {
346                 type inet:ipv4-address;
347                 description "Source IPv4 address (exact match)";
348             }
349             leaf dstIp {
350                 type inet:ipv4-address;
351                 description "Destination IPv4 address (exact match)";
352             }
353              leaf tos-byte {
354                  type tos-byte;
355                  description "TOS/DSCP match";
356              }
357              leaf tos-mask {
358                  type tos-byte;
359                  description "TOS/DSCP mask";
360              }
361              leaf protocol {
362                 type tp-protocol;
363                 description "IPv4 transport protocol";
364             }
365              leaf srcPort {
366                 type inet:port-number;
367                 description "TCP/UDP source port (exact match).";
368                }
369              leaf dstPort {
370                 type inet:port-number;
371                 description "TCP/UDP destination port (exact match).";
372                }
373              leaf priority {
374                type uint8;
375                description "Priority";
376                default 64;
377              }
378            }
379     }
380
381     grouping pcmm-qos-ext-classifier {
382         container ext-classifier {
383             leaf srcIp {
384                 type inet:ipv4-address;
385                 description "Source IPv4 address match";
386             }
387             leaf srcIpMask {
388                 type inet:ipv4-address;
389                 description "Source IPv4 mask";
390             }
391             leaf dstIp {
392                 type inet:ipv4-address;
393                 description "Destination IPv4 address match";
394             }
395             leaf dstIpMask {
396                 type inet:ipv4-address;
397                 description "Destination IPv4 mask";
398             }
399              leaf tos-byte {
400                  type tos-byte;
401                  description "TOS/DSCP match";
402              }
403              leaf tos-mask {
404                  type tos-byte;
405                  description "TOS/DSCP mask";
406              }
407              leaf protocol {
408                 type tp-protocol;
409                 description "IPv4 transport protocol";
410             }
411             uses tp-port-match-ranges;
412             leaf priority {
413               type uint8;
414               description "Priority";
415               default 64;
416             }
417            }
418     }
419
420     grouping pcmm-qos-ipv6-classifier {
421         container ipv6-classifier {
422             leaf srcIp6 {
423                 type inet:ipv6-prefix;
424                 description "Source IPv6 prefix match in  'address/len' notation";
425             }
426             leaf dstIp6 {
427                 type inet:ipv6-prefix;
428                 description "Destination IPv6 prefix match in 'address/len' notation";
429             }
430              leaf tc-low {
431                  type tos-byte;
432                  description "TC low range match";
433              }
434              leaf tc-high {
435                  type tos-byte;
436                  description "TC high range match";
437              }
438              leaf tc-mask {
439                  type tos-byte;
440                  description "TC mask";
441              }
442              leaf next-hdr {
443                 type tp-protocol;
444                 description "IPv6 Next Header";
445             }
446             leaf flow-label {
447                 type uint32 {
448                     range "0 .. 1048575";
449                 }
450                 description "IPv6 Flow Label (20 bits)";
451             }
452             uses tp-port-match-ranges;
453             leaf priority {
454               type uint8;
455               description "Priority";
456               default 64;
457             }
458            }
459     }
460
461             //RPCs
462     rpc ccap-set-connection {
463                 input {
464             leaf ccapId {
465                         type instance-identifier;
466                         ext:context-reference ccap-context;
467                 }
468                 container connection {
469                         leaf connected {
470                                 type boolean;
471                                 description "COPS session state";
472                         }
473 //                      leaf idle-detect {
474 //                                      type uint8;             
475 //                                      description "COPS connection idle timer";
476 //                              }
477                 }
478          }
479          output {
480                 container ccap {
481                         leaf ccapId {
482                                 type string;
483                         }
484                         container connection {
485                                         uses ccap-connection;
486                                 }
487                 }
488                 leaf response {
489                         type string;
490                 }
491                         leaf timestamp {
492                         type yang:date-and-time;
493                                 description "RPC timestamp";
494                 }
495          }
496     }
497     
498     rpc ccap-poll-connection {
499                 input {
500             leaf ccapId {
501                         type instance-identifier;
502                         ext:context-reference ccap-context;
503                 }
504          }
505          output {
506                 container ccap {
507                         leaf ccapId {
508                                 type string;
509                         }
510                         container connection {
511                                         uses ccap-connection;
512                                 }
513                 }
514                 leaf response {
515                         type string;
516                 }
517                         leaf timestamp {
518                         type yang:date-and-time;
519                                 description "RPC timestamp";
520                 }
521          }
522     }
523
524         rpc qos-poll-gates {
525                 input {
526             leaf appId {
527                 type instance-identifier;
528                         ext:context-reference app-context;
529                 }
530                 leaf subscriberId {
531                 type string;
532                 description "Subscriber Identity -- must be a CM or CPE IP address";
533                 }
534                 leaf gateId {
535                 type string;
536                 description "Qos Gate Identity";
537                 }
538          }
539          output {
540                         container gate {
541                                 uses gate-operational-attributes;
542                         }
543                         leaf response {
544                         type string;
545                 }
546                         leaf timestamp {
547                         type yang:date-and-time;
548                         description "RPC timestamp";
549                 }
550          }
551     }
552 }